Closed Jamoliddin2001 closed 2 years ago
hi,May I ask what caused this problem and how it was finally resolved? I also encountered this problem, looking for a solution
Assalamu alaikum. This is due to the creation of many exoplayer instances and the RAM will run out at some time. To do this, after the end of the video, you need to clear the exoplayer. I used Jetpack Compose and ExoPlayer and the code looks like this:
DisposableEffect(
AndroidView(
factory = { context ->
PlayerView(context).apply {
player = exoPlayer
player?.playWhenReady = true
resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FILL
useController = true
}
}
)
){
onDispose {
exoPlayer.release()
}
}
ExoPlayer
val mediaItem = MediaItem.fromUri(Uri.parse(URL))
val exoPlayer = remember(context) {
ExoPlayer.Builder(context).build().apply {
addListener(object : Listener {
override fun onPlaybackStateChanged(playbackState: Int) {
if (playbackState == STATE_ENDED) {
//TODO
}
super.onPlaybackStateChanged(playbackState)
}
override fun onPlayerError(error: PlaybackException) {
Log.d("TAG", "onPlayerError: ${error.message}")
super.onPlayerError(error)
}
})
setMediaSource(
ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(mediaItem)
)
prepare()
seekTo(0)
playbackDuration?.let(::seekTo)
}
}
Assalamu alaikum. I answered you can see GitHub https://github.com/danikula/AndroidVideoCache/issues/309.
Good luck to you.
Regards Jamoliddin :)
пн, 12 июн. 2023 г. в 17:04, 三三 @.***>:
hi,May I ask what caused this problem and how it was finally resolved? I also encountered this problem, looking for a solution
— Reply to this email directly, view it on GitHub https://github.com/danikula/AndroidVideoCache/issues/309#issuecomment-1587199473, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT3KKNH6FT566UAX7OJIP6DXK4ATHANCNFSM5UBVYZ3A . You are receiving this because you modified the open/close state.Message ID: @.***>
com.danikula.videocache.ProxyCacheException: Error pinging server (attempts: 3, max timeout: 280). If you see this message, please, report at https://github.com/danikula/AndroidVideoCache/issues/134. Default proxies are: [DIRECT]. Version: 2.7.1 at com.danikula.videocache.Pinger.ping(Pinger.java:73) at com.danikula.videocache.HttpProxyCacheServer.isAlive(HttpProxyCacheServer.java:185) at com.danikula.videocache.HttpProxyCacheServer.getProxyUrl(HttpProxyCacheServer.java:122) at com.danikula.videocache.HttpProxyCacheServer.getProxyUrl(HttpProxyCacheServer.java:103) at VideoPlayerKt.VideoPlayer(VideoPlayer.kt:47) at tj.livo.phoenix_tj.presentors.ui.widgets.GridGenerator.generateWidget(GridGenerator.kt:55) at tj.livo.phoenix_tj.presentors.ui.components.GagsGridKt.GagsGrid(GagsGrid.kt:63) at tj.livo.phoenix_tj.presentors.ui.screens.MainScreenKt$MainScreen$1.invoke(MainScreen.kt:125) at tj.livo.phoenix_tj.presentors.ui.screens.MainScreenKt$MainScreen$1.invoke(MainScreen.kt:75) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:140) at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2156) at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:2399) at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:2580) at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:2566) at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(SnapshotState.kt:540) at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:2566) at androidx.compose.runtime.ComposerImpl.recompose$runtime_release(Composer.kt:2542) at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:614) at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:764) at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:103) at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:447) at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:416) at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:34) at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.android.kt:109) at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.android.kt:41) at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.android.kt:69) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1008) at android.view.Choreographer.doCallbacks(Choreographer.java:809) at android.view.Choreographer.doFrame(Choreographer.java:740) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:995) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:246) at android.app.ActivityThread.main(ActivityThread.java:8595) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)