shaka-project / shaka-player-embedded

Shaka Player in a C++ Framework
Apache License 2.0
239 stars 62 forks source link

How to continue playing when the app enter background? #154

Open yukihiro-m-play opened 3 years ago

yukihiro-m-play commented 3 years ago

I tried the following in order to continue playing audio in the background, but the playback is paused when the iOS application enter background.

How to continue playing when the app enter background?

yukihiro-m-play commented 3 years ago

We would appreciate if you could response to my question. The detail procedure and expected behavior are as follows.

We expect the audio to be output continuously (background playback) by the following procedure, but the audio stops without continuing.

How to continue playing audio when the app enter background? Also, We want the app to control whether background playback is enabled or disabled, is that possible?

TheModMaker commented 3 years ago

Make sure that the ShakaPlayer instance still has another reference. If you only store it in the ShakaPlayerView, then when you remove it, the ShakaPlayer will be destroyed.

My guess is the OS is killing the process since we don't use iOS' thread scheduling to schedule background work. We may need to schedule some background tasks so the process keeps running. If we have to use iOS background tasks for all background work, this will be really difficult to add. We may be able to just schedule some fake events to keep the process alive.

kareljuricka commented 3 years ago

I just append more description about problem from logs. This errors show when app is moved background:


E1223 09:24:17.956127 1871097856 apple_decoder.cc:629] Error decoding frames: -12903

Got Shaka Player Error: Error decoding frames: -12903

Got Shaka Player Error: Shaka Error, Category: 3, Code: 3016

... workaround hack is to switch to native AV player during background and returning to shaka after app has moved back to foreground..