mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-22 08:00:32 +00:00
WIP: Inject (a local) NewPlayer into the NewPipe application
This is the basic setup that allows us to inject a NewPlayer instance into NewPipe. Frankenpipe, rise!
This commit is contained in:
parent
14081505cd
commit
4604a89137
@ -7,6 +7,7 @@ plugins {
|
||||
id "kotlin-android"
|
||||
id "kotlin-kapt"
|
||||
id "kotlin-parcelize"
|
||||
id "com.google.dagger.hilt.android"
|
||||
id "checkstyle"
|
||||
id "org.sonarqube" version "4.0.0.2929"
|
||||
}
|
||||
@ -208,6 +209,7 @@ dependencies {
|
||||
implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
|
||||
// WORKAROUND: v0.24.2 can't be resolved by jitpack -> use git commit hash instead
|
||||
implementation 'com.github.TeamNewPipe:NewPipeExtractor:ea1a1d1375efd5936ed2609d0fa3e31d5097a835'
|
||||
implementation 'com.github.TeamNewPipe:NewPlayer'
|
||||
implementation 'com.github.TeamNewPipe:NoNonsense-FilePicker:5.0.0'
|
||||
|
||||
/** Checkstyle **/
|
||||
@ -239,6 +241,8 @@ dependencies {
|
||||
implementation 'androidx.viewpager2:viewpager2:1.1.0-beta02'
|
||||
implementation "androidx.work:work-runtime-ktx:${androidxWorkVersion}"
|
||||
implementation "androidx.work:work-rxjava3:${androidxWorkVersion}"
|
||||
implementation 'com.google.dagger:hilt-android:2.52'
|
||||
kapt 'com.google.dagger:hilt-compiler:2.52'
|
||||
implementation 'com.google.android.material:material:1.11.0'
|
||||
|
||||
/** Third-party libraries **/
|
||||
|
@ -33,12 +33,15 @@ import java.net.SocketException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import dagger.hilt.android.HiltAndroidApp;
|
||||
import io.reactivex.rxjava3.exceptions.CompositeException;
|
||||
import io.reactivex.rxjava3.exceptions.MissingBackpressureException;
|
||||
import io.reactivex.rxjava3.exceptions.OnErrorNotImplementedException;
|
||||
import io.reactivex.rxjava3.exceptions.UndeliverableException;
|
||||
import io.reactivex.rxjava3.functions.Consumer;
|
||||
import io.reactivex.rxjava3.plugins.RxJavaPlugins;
|
||||
import kotlinx.coroutines.CoroutineScope;
|
||||
import kotlinx.coroutines.Dispatchers;
|
||||
|
||||
/*
|
||||
* Copyright (C) Hans-Christoph Steiner 2016 <hans@eds.org>
|
||||
@ -58,6 +61,7 @@ import io.reactivex.rxjava3.plugins.RxJavaPlugins;
|
||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@HiltAndroidApp
|
||||
public class App extends Application {
|
||||
public static final String PACKAGE_NAME = BuildConfig.APPLICATION_ID;
|
||||
private static final String TAG = App.class.toString();
|
||||
|
@ -58,6 +58,8 @@ import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
|
||||
import net.newpipe.newplayer.NewPlayer;
|
||||
|
||||
import org.schabi.newpipe.databinding.ActivityMainBinding;
|
||||
import org.schabi.newpipe.databinding.DrawerHeaderBinding;
|
||||
import org.schabi.newpipe.databinding.DrawerLayoutBinding;
|
||||
@ -98,11 +100,19 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.AndroidEntryPoint;
|
||||
|
||||
@AndroidEntryPoint
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
private static final String TAG = "MainActivity";
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public static final boolean DEBUG = !BuildConfig.BUILD_TYPE.equals("release");
|
||||
|
||||
@Inject
|
||||
NewPlayer newPlayer;
|
||||
|
||||
private ActivityMainBinding mainBinding;
|
||||
private DrawerHeaderBinding drawerHeaderBinding;
|
||||
private DrawerLayoutBinding drawerLayoutBinding;
|
||||
|
66
app/src/main/java/org/schabi/newpipe/NewPlayerComponent.kt
Normal file
66
app/src/main/java/org/schabi/newpipe/NewPlayerComponent.kt
Normal file
@ -0,0 +1,66 @@
|
||||
/* NewPlayer
|
||||
*
|
||||
* @author Christian Schabesberger
|
||||
*
|
||||
* Copyright (C) NewPipe e.V. 2024 <code(at)newpipe-ev.de>
|
||||
*
|
||||
* NewPlayer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* NewPlayer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with NewPlayer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.newpipe.newplayer.testapp
|
||||
|
||||
import android.app.Application
|
||||
import android.util.Log
|
||||
import androidx.core.graphics.drawable.IconCompat
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import net.newpipe.newplayer.NewPlayer
|
||||
import net.newpipe.newplayer.NewPlayerImpl
|
||||
import net.newpipe.newplayer.repository.CachingRepository
|
||||
import net.newpipe.newplayer.repository.PlaceHolderRepository
|
||||
import net.newpipe.newplayer.repository.PrefetchingRepository
|
||||
import org.schabi.newpipe.App
|
||||
import org.schabi.newpipe.MainActivity
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
object NewPlayerComponent {
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideNewPlayer(app: Application): NewPlayer {
|
||||
val player = NewPlayerImpl(
|
||||
app = app,
|
||||
repository = PrefetchingRepository(CachingRepository(PlaceHolderRepository())),
|
||||
notificationIcon = IconCompat.createWithResource(app, net.newpipe.newplayer.R.drawable.new_player_tiny_icon),
|
||||
playerActivityClass = MainActivity::class.java,
|
||||
// rescueStreamFault = …
|
||||
)
|
||||
if (app is App) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
while (true) {
|
||||
player.errorFlow.collect { e ->
|
||||
Log.e("NewPlayerException", e.stackTraceToString())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return player
|
||||
}
|
||||
}
|
@ -15,6 +15,10 @@ buildscript {
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.google.dagger.hilt.android' version '2.52' apply false
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
|
@ -9,3 +9,10 @@ include ':app'
|
||||
// substitute module('com.github.TeamNewPipe:NewPipeExtractor') using project(':extractor')
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
includeBuild('../NewPlayer') {
|
||||
dependencySubstitution {
|
||||
substitute module('com.github.TeamNewPipe:NewPlayer') using project(':new-player')
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user