Search code examples
androidchromecast

Playing M3U8 on Styled Media Receiver Chromecast


I am trying to play a M3U8 file from my Android sender like this:

   metaData = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE);
    metaData.putString(MediaMetadata.KEY_TITLE, "Demo Video");

    MediaInfo mediaInfo = new MediaInfo.Builder(
            "http://www.corsproxy.com/playertest.longtailvideo.com/adaptive/bbbfull/bbbfull.m3u8")
            .setContentType("application/vnd.apple.mpegurl")
            .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
            .setMetadata(metaData)
            .build();

player.load(client, mediaInfo, true)
          .setResultCallback(new ResultCallback<RemoteMediaPlayer.MediaChannelResult>() {
           @Override
           public void onResult(RemoteMediaPlayer.MediaChannelResult mediaChannelResult) {
                        Status status = mediaChannelResult.getStatus();
                                     if (status.isSuccess()) {
                                      }
                                      }
                                      });

However, I am getting the error

[cast.receiver.MediaManager] Load metadata error 
[cast.player.api.Player] error 
[cast.receiver.MediaManager] Load metadata error
[cast.receiver.MediaManager] Not sending LOAD error as there is no on going LOAD request

This is a Styled Media Receiver and its my understanding that it is using the Media Player Library so it should be able to handle M3U8 right? So I think this might be an error on my Sender part? Am I loading the m3u8 url correctly?


Solution

  • you could try exp/imp cycle on parsed m3u8 entries , subbing your m3su attrs in where u c "movieMetadata"...

    private static MediaInfo buildMediaInfo(String title,
            String subTitle, String studio, String url, String imgUrl, String bigImageUrl) {
        MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE);
    
        movieMetadata.putString(MediaMetadata.KEY_SUBTITLE, subTitle);
        movieMetadata.putString(MediaMetadata.KEY_TITLE, title);
        movieMetadata.putString(MediaMetadata.KEY_STUDIO, studio);
        movieMetadata.addImage(new WebImage(Uri.parse(imgUrl)));
        movieMetadata.addImage(new WebImage(Uri.parse(bigImageUrl)));
    
        return new MediaInfo.Builder(url)
                .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
                .setContentType(getMediaType())
                .setMetadata(movieMetadata)
                .build();
    }
    

    then when you have a MediaInfo ... you need the play event from something and you will need a looper at the end of each played item to signal a play event on the next MediaInfo entry. I built the loop using CCL lib and it plays lists of MediaInfo items.