How to play m3u8 on Android?

前端 未结 5 1224
半阙折子戏
半阙折子戏 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:28

    Following this link trail: http://code.google.com/p/android/issues/detail?id=14646

    ->

    http://code.google.com/p/android/issues/detail?id=16884

    ->

    http://code.google.com/p/android/issues/detail?id=17118

    (ARGGGGH!)

    Gives the answer in the end:

    basically in Android v2.3 & v3.0, use the non-standard httplive:// scheme, in 3.1 use http:// but with some code workaround in how you call the relevant methods in the media framework.

    0 讨论(0)
  • 2020-12-03 04:28

    You can use FFmpegMediaPlayer:

    https://github.com/wseemann/FFmpegMediaPlayer

    0 讨论(0)
  • 2020-12-03 04:32

    Try ExoMedia, streaming is as easy as:

    emVideoView.setVideoURI(Uri.parse("https://archive.org/download/Popeye_forPresident/Popeye_forPresident_512kb.mp4"));
    

    I works well with m3u8.

    0 讨论(0)
  • 2020-12-03 04:38

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

    activity_main.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >
    
        <VideoView
            android:id="@+id/myVideoView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>
    

    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.

    0 讨论(0)
  • 2020-12-03 04:44

    Maybe you can try the Vitamio plugin, http://vov.io/vitamio/

    Vitamio is a multimedia framework for all Android devices. Vitamio works like the Android's default MediaPlayer except that it includes much more powerful features. And it's absolutely free ! Network Protocols

    The following network protocols are supported for audio and video playback:

    MMS
    RTSP (RTP, SDP)
    HTTP progressive streaming
    HTTP live streaming (M3U8), for Android 2.1+
    
    0 讨论(0)
提交回复
热议问题