How to listen to progress on Google Cast in iOS

1.7k Views Asked by At

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

2

There are 2 best solutions below

4
On

It is recommended that you use the widgets provided by the SDK. They have been optimized to manage the media status efficiently. There are various ways you can customize and brand these widgets for your app.

2
On

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.