Reputation: 291
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
Upvotes: 2
Views: 1837
Reputation: 91
If it is not a live stream (i.e. 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);
Upvotes: 3
Reputation: 19034
There might be other issues as well, but the first issue I notice is that it is lacking CORS headers.
Upvotes: 1