Skip to content

Commit

Permalink
Feat(Exoplayer): Added additional codec support. (#528)
Browse files Browse the repository at this point in the history
* Add dependency

* Add Decoders to Builder

* Remove Comments
  • Loading branch information
Sadwhy authored Nov 18, 2024
1 parent 9fa326c commit a4bd367
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ dependencies {
// Media3 Casting
implementation "androidx.media3:media3-cast:$exo_version"
implementation "androidx.mediarouter:mediarouter:1.7.0"
// Media3 extension
implementation "com.github.anilbeesetti.nextlib:nextlib-media3ext:v0.7.0"

// UI
implementation 'com.google.android.material:material:1.12.0'
Expand Down
13 changes: 11 additions & 2 deletions app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ import androidx.media3.datasource.HttpDataSource
import androidx.media3.datasource.cache.CacheDataSource
import androidx.media3.datasource.okhttp.OkHttpDataSource
import androidx.media3.exoplayer.DefaultLoadControl
import androidx.media3.exoplayer.DefaultRenderersFactory
import androidx.media3.exoplayer.ExoPlayer
import androidx.media3.exoplayer.hls.HlsMediaSource
import androidx.media3.exoplayer.source.DefaultMediaSourceFactory
Expand Down Expand Up @@ -165,6 +166,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import io.github.anilbeesetti.nextlib.media3ext.ffdecoder.NextRenderersFactory
import java.util.Calendar
import java.util.Locale
import java.util.Timer
Expand Down Expand Up @@ -1700,7 +1702,14 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
.build()

hideSystemBars()
exoPlayer = ExoPlayer.Builder(this)

val decoder = DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER

val renderersFactory = NextRenderersFactory(this)
.setEnableDecoderFallback(true)
.setExtensionRendererMode(decoder)

exoPlayer = ExoPlayer.Builder(this, renderersFactory)
.setMediaSourceFactory(DefaultMediaSourceFactory(cacheFactory))
.setTrackSelector(trackSelector)
.setLoadControl(loadControl)
Expand Down Expand Up @@ -2382,4 +2391,4 @@ class CustomCastButton : MediaRouteButton {
true
}
}
}
}

0 comments on commit a4bd367

Please sign in to comment.