1

I using Google example for work with Chromecast.

Working with mp4 files is correct.

But if I want to use the m3u8 format, the video will not start playing.

If I rewind the video by 10 seconds ahead, it starts playing. But it doesn't play when rewinding from 0 to 9 seconds, even if you rewind before forward for more than 10 seconds.

This is my code:

func playVideoRemotely() {

    GCKCastContext.sharedInstance().presentDefaultExpandedMediaControls()

    let url = URL(string: "http://www.streambox.fr/playlists/test_001/stream.m3u8")

    guard let mediaURL = url else {
        print("invalid mediaURL")
        return
    }

    let mediaInfoBuilder = GCKMediaInformationBuilder(contentURL: mediaURL)

    mediaInfoBuilder.contentID = "http://www.streambox.fr/playlists/test_001/stream.m3u8"
    mediaInfoBuilder.streamType = GCKMediaStreamType.buffered
    mediaInfoBuilder.contentType = "video/m3u8"

    mediaInformation = mediaInfoBuilder.build()

    guard let mediaInfo = mediaInformation else {
        print("invalid mediaInformation")
        return
    }

    if let request = sessionManager.currentSession?.remoteMediaClient?.loadMedia(mediaInfo) {
        request.delegate = self
    }
}
maxwell
  • 3,788
  • 6
  • 26
  • 40

1 Answers1

0

I have not development on an iOS chromecast sender, but have done it on web. If you want the video to autoplay once it is loaded then I believe you need to set the autoplay field on the load options.