Sarwar Sateer
Sarwar Sateer

Reputation: 475

How to play any type of m8u3 live tv streaming on android?

I could play some of the live tv streams on my app, but I failed to play some of them. on VLC play I can play this: https://raw.githubusercontent.com/taodicakhia/IPTV_Exception/master/channels/af/tolotv.m3u8

and also this: http://51.210.227.142/hls/stream.m3u8

but in the android app, I can only play this one: http://51.210.227.142/hls/stream.m3u8 I tried a lot but I couldn't figure out how to play the first one: https://raw.githubusercontent.com/taodicakhia/IPTV_Exception/master/channels/af/tolotv.m3u8

This is my code:

private void playVideo() {
    try {
        getWindow().setFormat(PixelFormat.TRANSLUCENT);
        MediaController mediaController = new MediaController(AfghanistanTvAct.this);
        myVideoView.setMediaController(mediaController);
        Uri videoURI = Uri.parse(url);
        myVideoView.setVideoURI(videoURI);
        myVideoView.requestFocus();
        myVideoView.setOnPreparedListener(mp -> myVideoView.start());

    } catch (Exception e) {
        Toast.makeText(this, "" + e.getMessage(), Toast.LENGTH_SHORT).show();
    }
}

Upvotes: 0

Views: 775

Answers (1)

Mick
Mick

Reputation: 25491

If you look at the response from the servers in a browser inspector you will see that the MIME type, or content type, in the video that plays is:

  • application/vnd.apple.mpegurl

while the MIME type of the video that does not play is:

  • text/plain; charset=utf-8

I suspect this may be causing your issue.

Note that the video which does not play is also a master playlist - i.e. it contains links to other m3u8 files.

This is hard to verify as online HLS Analyser's and some test players seem to be able to handle this and still request the individual video streams, which do have the video MIME type, and will likely play for you if requested individually.

Upvotes: 0

Related Questions