stream live video to Android

前端 未结 4 1299
没有蜡笔的小新
没有蜡笔的小新 2020-12-07 18:13

How can I stream live video to Android (2.1 and higher), I have two links: m3u8 and f4m (As I know, f4m is not supported).

From what I saw

4条回答
  •  旧时难觅i
    2020-12-07 18:51

    Because no one answered my question, I will do it myself.

    If you want to perform HLT (HTTP Live Stream) on Android 2.1 and higher you may use the vitamio library.

    Site at: (http://www.vitamio.org/).

    Here is code example: The main layout:

    
    
    
    
                               
                
    
    

    the Class:

    import io.vov.vitamio.widget.MediaController;
    import io.vov.vitamio.widget.VideoView;
    import android.app.Activity;
    import android.content.Intent;
    import android.net.Uri;
    import android.os.Bundle;
    
    
    
    public class LiveStrimingTestActivity extends Activity{
    
        VideoView videoView;
    
        private void test_2(){
            String httpLiveUrl = "http://aj.lsops.net/live/aljazeer_en_high.sdp/playlist.m3u8";   
            videoView = (VideoView) findViewById(R.id.VideoView);
            videoView.setVideoURI(Uri.parse(httpLiveUrl));
            MediaController mediaController = new MediaController(this);
            videoView.setMediaController(mediaController);
            videoView.requestFocus();
            videoView.start();
        }
    
    
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            test_2();             
        }     
    }
    

提交回复
热议问题