ExoPlayer stop playing on lock

Created on 28 Mar 2020  路  10Comments  路  Source: google/ExoPlayer

i am developing a audio player app using exoplayer which works great but i found one weird problem some times it's stop to play song automatically may be after 5-6 song play.

app is not crashing just song stop to play after some long time

i try to debug issue but i couldn't find any issue it's working fine

please help me @marcbaechinger what is wrong? suggest me

Any help would be highly appreciated.

question

All 10 comments

Is the app holding a wake lock to prevent the device sleeping? If not, please try calling SimpleExoPlayer.setWakeMode(C.WAKE_MODE_LOCAL) or SimpleExoPlayer.setWakeMode(C.WAKE_MODE_REMOTE (depending on whether you are playing local/remote media) when you initialize the player. Note: to use this feature, you must add the WAKE_LOCK permission to your application's manifest file. See also Keep the device awake and #5846.

not resolve C.WAKE_MODE_LOCAL

is exoPlayer.setHandleWakeLock(true) work same?

Ah, setting wake mode hasn't been released yet (but it should be on the dev-v2 branch in case you want to try it out!).

Yes, please use setHandleWakeLock instead for now. Thanks.

i am still facing same issue after adding
<uses-permission android:name="android.permission.WAKE_LOCK" />
and
exoPlayer.setHandleWakeLock(true)

i wrote same exact code for music player

```
private fun prepareExoPlayerFromURL() {

    val dataSourceFactory =
        DefaultDataSourceFactory(this, Util.getUserAgent(this, resources.getString(R.string.app_name)), null)

    val concateMediaSource = ConcatenatingMediaSource()
    for (i in mSongList) {
        val mediaSource = ProgressiveMediaSource
            .Factory(
                DefaultDataSourceFactory(this, dataSourceFactory),
                DefaultExtractorsFactory()
            )
            .createMediaSource(Uri.parse(i.musicFile)/*Uri.parse(i.uri)*/)
        concateMediaSource.addMediaSource(mediaSource)
    }



    exoPlayer.prepare(concateMediaSource)
    exoPlayer.seekToDefaultPosition(songPosition)
    exoPlayer.setHandleWakeLock(true)
    initSeekBar()

    setNotification()
}

```

Please could you take bug reports via adb bugreport (1) just after starting playback and (2) just after playback stops? You can email those to dev.[email protected] with subject 'Issue #7157' and we will take a look. Thanks.

I wonder whether what's missing is a WiFi lock. Before getting the bug reports, you could try checking out the dev-v2 branch and trying the remote wake mode.

do you have any reference for how do i report bug using adb or steps to report?

You can just run adb bugreport on the command line if you have adb installed and the device is connected. See also Capture and read bug reports.

Please also confirm you are using a foreground service for audio playback. See also this FAQ.

i am not using foreground service i am playing from MainActivity
it's not our requirement to play after app close that's why i am playing from MainActivity

would it cause any problem?

Yes. You need to use a Service for this use case (the system can kill activities when they aren't in the foreground).

Was this page helpful?
0 / 5 - 0 ratings