1

I have created a following playlist:

#EXTM3U
#EXTINF:3,File - 1
http://pilatus.d1.comp.nus.edu.sg/~a0095695/video_repo/1.mp4
#EXTINF:3,File - 2
http://pilatus.d1.comp.nus.edu.sg/~a0095695/video_repo/2.mp4
#EXTINF:-1,File - 3
http://pilatus.d1.comp.nus.edu.sg/~a0095695/video_repo/3.mp4
#EXT-X-ENDLIST

Also I am using this code to play on my Android device:

MediaController mc = new MediaController(this);
VideoView videoview = (VideoView)findViewById(R.id.myvideoview);        
mc.setMediaPlayer(videoview);
videoview.setMediaController(mc);
videoview.setVideoURI(Uri.parse("http://pilatus.d1.comp.nus.edu.sg/~a0095695/video_repo/playlist.m3u8"));
videoview.requestFocus();
videoview.start();

I want Dash streaming, so would create another set of m3u8 files on top of it adapting to the bandwidth

The problem is that I am getting error like "Cannot play the file"

What am I doing wrong?...

Thanks

  • Try the only play `http://pilatus.d1.comp.nus.edu.sg/~a0095695/video_repo/1.mp4` – Leandros Oct 06 '12 at 16:27
  • Yes. Mp4 is working fine, but i need to play m3u8 playlist on android device. Thanks for your help but. :) – Mobashyr Mohammad Oct 08 '12 at 15:22
  • It's simple, just open the the file in Android and parse the URLs to your player. Theres no other solution. – Leandros Oct 08 '12 at 15:28
  • Thanks. Indeed its playing now. The next task for me is to create a MPEG-DASH player for android. Is there any tutorial to begin with? I read MP4Box can be used to segment out the mp4 file on the server to create segments and corresponding mpd file. Now that I have these, how can I proceed to stream the segments adaptively on android 4.0.3? – Mobashyr Mohammad Oct 10 '12 at 15:29

3 Answers3

4

that is a HLS streaming, and Android 4.0 don't have problems with this format. toyr code are wrong, try to use :

VideoView videoview = (VideoView)findViewById(R.id.myvideoview);        
videoview.setMediaController(new MediaController(this));
videoview.setVideoURI(Uri.parse("http://pilatus.d1.comp.nus.edu.sg/~a0095695/video_repo/playlist.m3u8"));
videoview.requestFocus();
videoview.setOnPreparedListener(new OnPreparedListener() {
        public void onPrepared(MediaPlayer mp) {
            mp.start();
        }
    });
Rodrigo Amaro Reveco
  • 4,932
  • 5
  • 22
  • 33
1

Android's support for M3U8 playlist is limited. Only newer devices supports the playlist. Some people mentioned they've had luck with devices 2.3.x. As far as I know, this feature was made available in Android 3.0.

See the new features documentation

If you have a supported device to test with and still experience issues, try using the httplive protocol

A mp4 file should play, however.

krg
  • 2,650
  • 2
  • 12
  • 9
  • Thanks for giving time to my problem :). I tried to play the mp4 file directly and its working fine.I recently created transport stream (.ts) using ffmpeg and added to my m3u8 playlist. But again when I try to play it on my Android 4.0.4 Asus Transformer tablet, it displays no streams. Is my m3u8 file incorrect? I even tried playing on iPad and its not playing. – Mobashyr Mohammad Oct 08 '12 at 15:18
1

This is an example of how to play .M3U8 Streaming in Android, but like other programmers says is not fully supported in all the Android devices

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.

Jorgesys
  • 124,308
  • 23
  • 334
  • 268