1

I have a new problem, a bit strange. I tried videoview 4 devices. And after 20 seconds it blocks the image. The sound goes. I tried to add "setLayerType (View.LAYER_TYPE_SOFTWARE, null);" but does not help, on the contrary does not appear at all image than black. It can solve?

    import android.app.ProgressDialog;
import android.graphics.PixelFormat;
import android.media.MediaPlayer;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import android.view.View;
import android.widget.MediaController;
import android.widget.VideoView;


public class Player extends AppCompatActivity {

    private static ProgressDialog progressDialog;

    String videourl = "http://xxxxxxxx/playlist.m3u8";
    VideoView videoView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_player);

        videoView = (VideoView) findViewById(R.id.myVideoView);

        progressDialog = ProgressDialog.show(Player.this, "", "Buffering video...", true);
        progressDialog.setCancelable(false);

        PlayVideo();
    }

    private void PlayVideo() {
        try {
            getWindow().setFormat(PixelFormat.TRANSLUCENT);

            MediaController mediaController = new MediaController(Player.this);
            mediaController.setAnchorView(videoView);

            Uri video = Uri.parse(videourl);
            videoView.setMediaController(mediaController);
            videoView.setVideoURI(video);
            videoView.requestFocus();
            videoView.setVisibility(View.VISIBLE);

            videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

                public void onPrepared(MediaPlayer mp) {
                    progressDialog.dismiss();
                    videoView.start();

                }
            });

        } catch (Exception e) {
            progressDialog.dismiss();
            System.out.println("Video Play Error :" + e.toString());
            finish();
        }

    }

}
diaconu liviu
  • 1,032
  • 2
  • 13
  • 30

1 Answers1

1

Well, i have experienced the same, .m3u8 format files are not fully supported in android, i fact some devices will play the video and others will stop at some point.

If you have to play only .m3u8 files, i recommend to try with another players for example: VITAMIO player

in fact .m3u8 format is not listed as supported by Android OS: Android Supported Media Formats

check another of my answers: How to play m3u8 on Android?

Community
  • 1
  • 1
Jorgesys
  • 124,308
  • 23
  • 334
  • 268
  • I personally think that the real problem is hardware. In Snapdragon CPU 805 (nexus6) go right. In intel cpu nexus player, do not go. Asus intel cpu zenfone2 just black screen. In nvidia shield here as black screen tv. But in September nexus cpu nvidia k1 go smoothly. So my opinion is a problem that affects only certain processors. – diaconu liviu Dec 17 '15 at 19:56