简体   繁体   中英

Cast HLS Live stream URL to Cast Device with Cast Companion Library

I want to cast HLS Live stream to Cast Device using Cast Companion Library Android. I try the url but failed to play on Cast Device. When using VOD HLS URL, the video can play on Cast Device.

I am already change the streamType: MediaInfo.Builder(url).setStreamType(MediaInfo.STREAM_TYPE_LIVE)

Or anything else I must change ?

This is the Live stream URL I want to cast: http://vevoplaylist-live.hls.adaptive.level3.net/vevo/ch3/appleman.m3u8

How to cast HLS Live stream using Cast Companion Library Android? Anyone already try this, or if there is any sample code that I can learn?

Thanks

If it is not a live stream (ie if the duration is known) you should use MediaInfo.STREAM_TYPE_BUFFERED, and for HLS you should set the content type to "application/x-mpegURL".

Overall it should look something like this:

MediaMetadata mediaMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE);
mediaMetadata.putString(MediaMetadata.KEY_TITLE, "Media Title");

MediaInfo mSelectedMedia = new MediaInfo.Builder(
    "http://vevoplaylist-live.hls.adaptive.level3.net/vevo/ch3/appleman.m3u8")
    .setContentType("application/x-mpegURL")
    .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
    .setMetadata(mediaMetadata)
    .build();


int startPosition = 0;
boolean autoPlay = true;

mCastManager.startVideoCastControllerActivity(getContext(), mSelectedMedia, startPosition, autoPlay);

可能还有其他问题,但是我注意到的第一个问题是它缺少CORS标头。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM