Reputation: 9887
I am developing a ChromeCast app that instances a YoutubeSupportFragment
in the presentation display.
My problem is, when the app goes background, Youtube video is stopped. I've traced that YoutubeSupportFragment's onPause
pauses the video.
Is there a way to somehow attach the fragment lifecycle to the CastRemoteDisplayLocalService
so fragment's onPause
is not called?
I've tried to set the fragment as retained with setRetainInstance
but no luck :(
Upvotes: 2
Views: 117
Reputation: 1737
I believe @noogui is correct in that you can't disable onPause
. Making it easy to bind the state of fragments/activities to a persistent service would defeat the purpose of having fragments/activities; Android wants to be able to kill the YoutubeSupportFragment
if memory runs low.
I haven't tried this, but there may be an alternative route. You can display an iframe
in a receiver app per this answer, and there is an API for embedding the Youtube video player in an iframe
. So instead of using the Cast RemoteDisplayAPI
, why not write a custom receiver app to hold the video player? This should allow you to continue playing video whether or not the Android app is backgrounded.
Upvotes: 0
Reputation: 17613
I dont think there's a way of disabling onPause as it is at the core of the Anroid lifecycle.
Upvotes: 1