Search code examples
androidvideovideo-streamingchromecastgoogle-cast

Casting m3u8 file from android app


I am trying to play a video on my TV using chromecasting framework provided. The approach i followed for playing a mp4 works fine. But now i have different source to play. I have a video file pointed by m3u8 file placed on my server. So, for playing m3u8 file on TV i am using the following MediaInfo object with variants for content-type mentioned here. The MediaObject i am returning is:`

return new MediaInfo.Builder(Uri.parse(path).toString())
            .setStreamType(MediaInfo.STREAM_TYPE_LIVE)
            .setContentType("videos/mp4") //need to know **what should be content-type here**
            .setMetadata(movieMetadata)
            .setStreamDuration(mSelectedMedia.getData().getDuration() * 1000)
            .build();

Please guide me for playing m3u8 file on my chromecast or TV. Thanks


Solution

  • First of all, I don't see what issue you are running into; always include that in your post so that you can get a better response. Based on the description you have provided, it seems like you are casting a playlist pointing at some files; if that is the case, you shouldn't set the stream type to live stream, instead use the buffered type (like what you would do for a simple mp4). Secondly, what receiver are you using? Your receiver should be capable of handling m3u8 playlist. If you use a Styled or the Default receiver (or use the Reference receiver from our GitHub repo, then you should be fine. Finally, make sure you are using https for the vide streams (for playlists it is required) and also that your server supports CORS headers.