5

Observed behavior: After starting the casting of music files, user enters the background. After a few minutes of playing the music file through cast, session gets suspended with the reason GCKConnectionSuspendReasonNetworkNotReachable, even though the sender device and cast device both are connected to a working Wi-Fi connection

Expected Behavior: The session should continue as the sender app has the background capability of playing audio and also with GCKCastOptions we have set the property suspendSessionsWhenBackgrounded to NO.

Ronak Chaniyara
  • 5,335
  • 3
  • 24
  • 51
Vikas Dadheech
  • 1,672
  • 12
  • 23

1 Answers1

0

You may want to check resuming after app backgrounding in GCKRemoteDisplayChannel Class

It's stated that,

Normally when an iOS app goes to the background, all network connections are closed and all hardware encoder access is terminated. This effectively means that without special handling a Remote Display session will end upon app backgrounding.

A session can be kept alive in the background by doing the following:

  • Initialize the GCKDeviceManager with initWithDevice:clientPackageName:ignoreAppStateNotifications:, specifying YES as the ignoreAppStateNotifications argument.
  • Register a background task using UIApplication beginBackgroundTaskWithExpirationHandler: to keep the app running if it is backgrounded for an amount of time controlled by iOS.

For more information, you may want to also check Playing media while in the background using AV Foundation on iOS.

Community
  • 1
  • 1
Teyam
  • 7,686
  • 3
  • 15
  • 22
  • The link redirects to a reference page of v2 of sdk. I couldn't find this option in latest v3 of sdk. And UIApplication beginBackgroundTaskWithExpirationHandler: is also not helpful in this case. And this link is for playing audio on device not on chromecast while app is in background. If you read the expected behaviour section of the question - it clearly states that the sender app has the capability of playing audio in background. https://developer.apple.com/library/content/qa/qa1668/_index.html#//apple_ref/doc/uid/DTS40010209 – Vikas Dadheech Aug 31 '17 at 09:43