How to play m3u8 on Android?

前端 未结 5 1260
半阙折子戏
半阙折子戏 2020-12-03 04:05

As i understood, Android 3.0 and above are able for play radio streaming m3u8 - http://developer.android.com/guide/appendix/media-formats.html

I put this link - http

5条回答
  •  孤街浪徒
    2020-12-03 04:38

    This is my example of how to play .M3U8 Streaming in Android

    activity_main.xml

    
    
    
        
    
    

    Main.java

    package com.grexample.ooyalalive;
    
    import java.net.URL;
    import android.app.Activity;
    import android.net.Uri;
    import android.os.Bundle;
    import android.widget.MediaController;
    import android.widget.VideoView;
    
    public class Main extends Activity {
    
        private String urlStream;
        private VideoView myVideoView;
        private URL url;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main_vv);//***************
                myVideoView = (VideoView)this.findViewById(R.id.myVideoView);
                MediaController mc = new MediaController(this);
                myVideoView.setMediaController(mc);         
                urlStream = "http://jorgesys.net/i/irina_delivery@117489/master.m3u8";
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        myVideoView.setVideoURI(Uri.parse(urlStream)); 
                    }
                });
        }
    }
    

    I have seen a lot of people have problems playing .M3U8, it depends on the codecs used for the streaming and compatibility with the device, for example some of my .m3u8 files are only supported in devices with screens of 1200 x800 and higher.

提交回复
热议问题