1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| progressDialog = ProgressDialog.show(PlayVideo.this, "", "Buffering Video");
progressDialog.setCancelable(true);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
videoView = (VideoView)findViewById(R.id.VideoView);
this.mediaController = new MediaController(PlayVideo.this);
mediaController.setAnchorView(videoView);
//same url used in VLC
String urlHttpManOfSteel = "http://192.168.1.79:80/manofsteel";
String testUrl = urlHttpManOfSteel;
Uri videoUri = Uri.parse(testUrl);
videoView.setVideoURI(videoUri);
videoView.requestFocus();
videoView.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
progressDialog.dismiss();
videoView.start();
}
});
videoView.setOnErrorListener(new OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
String title = "Unable to read video";
String message = "mp : "+mp + "\n what :"+what+"\n extra : "+extra;
AlertDialog dialog = customDialog(title, message, context);
dialog.show();
System.out.println("mp : "+mp + "\n what :"+what+"\n extra : "+extra);
return false;
}
}); |
Partager