Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to listen to progress on Google Cast in iOS

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

like image 254
Martin Vandzura Avatar asked Nov 09 '18 09:11

Martin Vandzura


People also ask

Does Google chromecast support iOS?

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.

How do I airplay to Chromecast Audio?

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.


1 Answers

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.

like image 143
Quang Dam Avatar answered Oct 08 '22 22:10

Quang Dam