0

I ve a m3u8 link which works fine on vlc but when working on mediaPlayer for android and passing m3u8 url link i got this error:

Error:

setDataSource: IOException! uri=http://46.166.162.35:9090/load/b0922f3fa8aa/35.m3u8
 error (1, -2147483648)
Prepare failed.: status=0x1

I also have meet this MediaPlayer.setDataSource(String) not working with local files but failed to resolve. I dont know where i am doing wrong. Have a look.

Here is my code.

  String URL="http://46.166.162.35:9090/load/b0922f3fa8aa/35.m3u8";//ss1
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.video);
    view = (VideoView)findViewById(R.id.videoView1);
    pd = new ProgressDialog(Show340.this);

    pd.setTitle("Video Streaming....");
    pd.setMessage("Buffering..");
    pd.setIndeterminate(false);
    pd.setCancelable(false);
    pd.show();

    try{
        MediaController controller = new MediaController(Show340.this);
        MediaPlayer mp = new MediaPlayer();
        controller.setAnchorView(view);
        Uri vid = Uri.parse(URL);
        mp.setDataSource(Show340.this,vid);
        mp.prepare();
        mp.start();
    /*  Uri vid = Uri.parse(URL);*/
        view.setMediaController(controller);
        view.setVideoURI(vid);
        mp.release();
    }catch(Exception e){
        Log.e("Error",e.getMessage());
        e.printStackTrace();


    }
    view.requestFocus();
    view.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

        public void onPrepared(MediaPlayer mp) {
            // TODO Auto-generated method stub
            pd.dismiss();
            view.start();

        }
    });
    view.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {

        @Override
        public void onCompletion(MediaPlayer mp) {
            // TODO Auto-generated method stub
            if(pd.isShowing()){
                pd.dismiss();
            }
            finish();
        }
    });
}
Community
  • 1
  • 1
user3162878
  • 598
  • 3
  • 10
  • 25
  • I just have tested the link, it doesn't work. You sure the url is valid? Otherwise try to rename the extension of url, from ".m3u8" to ".m3u" – Tirolel Oct 11 '16 at 11:45
  • yh it works on vlc. even this is also working on vlc http://46.166.162.35:9090/load/b0922f3fa8aa/4.m3u8 but not on android media player – user3162878 Oct 11 '16 at 15:48
  • actually i ve playlist having many such links. all are working on vlc but not on android media. – user3162878 Oct 11 '16 at 15:50
  • why did you release the media player? I guess it might be the reason – A_rmas Apr 16 '18 at 05:59

0 Answers0