Play m3u8 video in android

前端 未结 6 511
被撕碎了的回忆
被撕碎了的回忆 2021-01-30 18:00

I want to live streaming the video and it is in m3u8 format. So i tried the below code

public class StreamingPlayer extends Activity implements
OnBufferingUpdate         


        
6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-30 18:33

    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";
    
                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.

提交回复
热议问题