diff --git a/app/build.gradle.kts b/app/build.gradle.kts index cfd7663..cbe7e99 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -84,26 +84,29 @@ android { } dependencies { - implementation("androidx.core:core-ktx:1.12.0") + implementation("androidx.core:core-ktx:1.13.1") implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.6.3") implementation("org.jetbrains.kotlinx:kotlinx-serialization-cbor:1.6.3") implementation("androidx.core:core-splashscreen:1.0.1") - implementation(platform("androidx.compose:compose-bom:2024.02.02")) + implementation(platform("androidx.compose:compose-bom:2024.05.00")) implementation("androidx.compose.material3:material3") - implementation("androidx.tv:tv-material:1.0.0-alpha10") + implementation("androidx.tv:tv-material:1.0.0-beta01") implementation("io.coil-kt:coil-compose:2.6.0") implementation("androidx.navigation:navigation-compose:2.7.7") - implementation("androidx.compose.material:material-icons-extended:1.6.3") - - implementation("androidx.media3:media3-exoplayer:1.3.0") - implementation("androidx.media3:media3-exoplayer-hls:1.3.0") - implementation("androidx.media3:media3-exoplayer-dash:1.3.0") - implementation("androidx.media3:media3-ui:1.3.0") + implementation("androidx.compose.material:material-icons-extended:1.6.7") + + implementation("androidx.media3:media3-exoplayer:1.3.1") + implementation("androidx.media3:media3-exoplayer-hls:1.3.1") + implementation("androidx.media3:media3-exoplayer-dash:1.3.1") + implementation("androidx.media3:media3-ui:1.3.1") + implementation("com.github.anilbeesetti.nextlib:nextlib-media3ext:0.7.1") + implementation("com.github.anilbeesetti.nextlib:nextlib-mediainfo:0.7.1") + implementation("com.github.bjoernpetersen:m3u-parser:1.4.0") } \ No newline at end of file diff --git a/app/src/main/java/dev/khaled/leanstream/player/PlayerScreen.kt b/app/src/main/java/dev/khaled/leanstream/player/PlayerScreen.kt index eb2de13..9a57b10 100644 --- a/app/src/main/java/dev/khaled/leanstream/player/PlayerScreen.kt +++ b/app/src/main/java/dev/khaled/leanstream/player/PlayerScreen.kt @@ -3,6 +3,7 @@ package dev.khaled.leanstream.player import android.content.Context import android.net.Uri import androidx.activity.compose.BackHandler +import androidx.annotation.OptIn import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -12,17 +13,20 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.viewinterop.AndroidView import androidx.media3.common.MediaItem import androidx.media3.common.MediaMetadata +import androidx.media3.common.util.UnstableApi +import androidx.media3.exoplayer.DefaultRenderersFactory import androidx.media3.exoplayer.ExoPlayer import androidx.media3.ui.PlayerView import dev.khaled.leanstream.channels.Channel import dev.khaled.leanstream.player.controller.PlayerController +import io.github.anilbeesetti.nextlib.media3ext.ffdecoder.NextRenderersFactory @Composable fun PlayerScreen(channel: Channel, playlist: List, navigateBack: () -> Unit) { val exoPlayer = rememberExoPlayer(LocalContext.current) - LaunchedEffect(Unit) { + // FIXME OOM When playlist large af playlist.forEach { exoPlayer.addMediaItem( MediaItem.Builder().setUri(it.url).setMediaMetadata( @@ -52,9 +56,15 @@ fun PlayerScreen(channel: Channel, playlist: List, navigateBack: () -> } +@OptIn(UnstableApi::class) @Composable private fun rememberExoPlayer(context: Context) = remember { - ExoPlayer.Builder(context).build().apply { - playWhenReady = true - } + val renderersFactory = NextRenderersFactory(context).setExtensionRendererMode( + DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON + ) + + ExoPlayer.Builder(context).setRenderersFactory(renderersFactory) + .build().apply { + playWhenReady = true + } } diff --git a/settings.gradle.kts b/settings.gradle.kts index 907fd8d..58fb465 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -3,6 +3,7 @@ pluginManagement { google() mavenCentral() gradlePluginPortal() + maven { url = uri("https://jitpack.io") } } } dependencyResolutionManagement { @@ -10,6 +11,7 @@ dependencyResolutionManagement { repositories { google() mavenCentral() + maven { url = uri("https://jitpack.io") } } }