0
votes

We are trying to play HLS video on Chromecast device. We have enabled CORS. We can successfully play a normal HLS video. but we have problem with URL hashing.

We send chromecast, an url with hashing (for security purpose) Example: http://domainname.com/70000871V/70000871V.m3u8?cp=%2FsFcurrent%2F70000871V%2F*&cf=1403&e=1493&h=cbc90

The above is basically an m3u8 video index file, chromecast looks into the index file and chooses a resolution to play, when it accesses the child file, it removes the hashing provided in the url. This results in chromecast not able to access the child file because it removed the hashing paramaters in url.

Consider m3u8 file contains some files like 70000871V_iphone_med.m3u8, so when it tries to access them, it removes the hashing...

How to tell chromecast to keep the hashing parameters when it accesses the index file.

Note: This url successfully playing in Mobile device.

The Console showing the below issue:

### MEDIA ELEMENT LOAD START sample_media_receiver.html:573

XMLHttpRequest cannot load http://domainname.com/s/web_vod/current/90002466V/ROTOX013V_iphone_med.m3u8. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://' is therefore not allowed access. sample_media_receiver.html:1

HOST ERROR - Fatal Error: code = 3 sample_media_receiver.html:487

### MEDIA ELEMENT STALLED

video url: http://domainname.com/70000871V/70000871V.m3u8?cp=%2FsFcurrent%2F70000871V%2F*&cf=1403&e=1493&h=cbc90

The .m3u8 file has,

EXTM3U

EXT-X-VERSION:3

EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2037261,CODECS="avc1.4d001f,mp4a.40.5",RESOLUTION=960x540

ROTOX013V_iphone_hi.m3u8

EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=740606,CODECS="avc1.66.30,mp4a.40.5",RESOLUTION=640x360

ROTOX013V_iphone_med.m3u8

EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=296618,CODECS="avc1.66.30,mp4a.40.5",RESOLUTION=416x234

ROTOX013V_iphone_low.m3u8

EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=5094217,CODECS="avc1.4d001f,mp4a.40.5",RESOLUTION=1280x720

ROTOX013V_ipad_hi.m3u8

How to make this?

2

2 Answers

0
votes

you might want to look at chromecast's mediaList/MediaInfo.

and at a sample implementation thereof. -> 'buildMedia()'

Chromecast media support does not have built in support for m3u8 lists.

Instead of trying to push m3u8 handling down into a stack that does not support it, you might want to implement a simple List wrapper at the interface ??

Like "m3u8-to-mediaInfoList" and "mediainfoList-to-m3u8".

OR

do it at the list item level. If you look at that 'buildMedia' method in the source, its a good example of how to get a MediaInfo item from a m3u8 item.

minor mods to one of the CC samples on github....

   public static List<MediaInfo> buildMedia(String url, Context ctx) throws JSONException {
//check nulls
        mediaList = new ArrayList<MediaInfo>();
        JSONObject jsonObj = new VideoProvider().parseUrl(url, ctx);
        JSONArray categories = jsonObj.getJSONArray(TAG_RESULTS);
        if (null != categories) {
            for (int i = 0; i < categories.length(); i++) {                                       
                JSONObject category = categories.getJSONObject(i);
                String title = category.getString(TAG_MSG);
                String subTitle = category.getString(TAG_MSG);                 
                JSONObject media3 = category.getJSONObject(TAG_MEDIA3);
                String videoUrl = media3.getString(TAG_URL);               
                JSONObject media4 = category.getJSONObject(TAG_MEDIA4);
                String imageurl = media4.getString(TAG_URL); 
                String bigImageurl = media4.getString(TAG_URL);

                String studio = category.getJSONObject(TAG_CREATEDBY).getString(TAG_USERNAME);
                mediaList.add(buildMediaInfo(title, studio, subTitle, videoUrl, imageurl,
                     bigImageurl));
                Log.d(TAG, "MediaInf " +i +" " +imageurl +" " +bigImageurl +" " +videoUrl);
            }
        }
        return mediaList;
    }
0
votes

You need to write a custom receiver (using MPL) and use host overrides updateManifestRequestInfo / updateSegmentRequestInfo to achieve the desired behavior.