How can I listen to progress on Google Cast in iOS? I have implemented cast support in my app based on https://github.com/googlecast/CastVideos-ios but I don't want to use their GCKUIExpandedMediaControlsViewController class to control playback.
I added GCKRemoteMediaClientListener to GCKCastSession's GCKRemoteMediaClient. It calls
public func remoteMediaClient(_ client: GCKRemoteMediaClient, didUpdate mediaStatus: GCKMediaStatus?) {
print("position: \(mediaStatus?.streamPosition)")
}
But it's called every 10 seconds and I would like to get progress every second. Is there some way to do it? Or I have to implement my own timer and check current stream position every second?
Thanks
Connect your iPhone or iPad and your Chromecast to the same wireless network. On your iPhone or iPad, open the Google TV app . Movies or TV shows.
For Android devices it's easy: Open the Apple Music app and start playing a song. Tap the Cast icon near the top right-hand corner of the screen. Select the name of your Chromecast device.
Same as your problem. After trying to find the solution for that issue, I use GCKUIMediaController
to handle the progress timer.
_mediaController = [[GCKUIMediaController alloc] init];
_mediaController.playPauseToggleButton = _playButton;
_mediaController.nextButton = _nextButton;
_mediaController.previousButton = _previousButton;
_mediaController.streamPositionSlider = _timeSlider;
_mediaController.streamPositionLabel = _playedTimeLabel;
_mediaController.streamDurationLabel = _durationTimeLabel;
_mediaController.delegate = self;
Snip code above is an example I think can help you, I have used it for my project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With