I've been having trouble making Google Cast SDK work properly for a week now. I have successfully established a connection with Chromecast receiver, at least the logs say so in so does my GCKSessionManagerListener.
This is how far my application flow gets at the moment:
I start a live stream video in AVPlayer (u3m8 format)
Wait for Google Cast button to become visible on the navigation bar
Then I select my Chromecast receiver.
On SessionManagerListener - didStart (connection has been established) I request loadMedia on currentCastSession of SessionManager, I also tried loading queues, audio, image, nothing triggers Default Receiver App to appear. I hope someone will find a flaw in code/logic. This is all the relevant code:
Initialize on Application start:
let options = GCKCastOptions(discoveryCriteria:
.init(applicationID: kGCKDefaultMediaReceiverApplicationID))
GCKCastContext.setSharedInstanceWith(options)
GCKLogger.sharedInstance().delegate = self
Building button:
let frame = CGRect(x: 0, y: 0, width: 24, height: 24)
let castButton = GCKUICastButton(frame: frame)
castButton.tintColor = UIColor.white
return UIBarButtonItem(customView: castButton)
On my SessionManagerListener ->
func sessionManager(_ sessionManager: GCKSessionManager, didStart session: GCKSession) {
let mediaInfo = GCKMediaInformation(contentID: url, streamType: .live,
contentType: "video/m3u", metadata: nil, adBreaks: nil,
adBreakClips: nil, streamDuration: .infinity,
mediaTracks: nil, textTrackStyle: nil, customData: nil)
print("loading media: \(String(describing: mediaInfo))")
let request = sessionManager.currentCastSession?
.remoteMediaClient?.loadMedia(mediaInfo)
request?.delegate = self
}
I have simply run out of ideas and I'm turning to you guys for help, thank you all for your time!