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 39 40 41 42 43 44 45
| @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
v = (VideoView)findViewById(R.id.VideoView);
String videoSrc = "rtsp://root:root@134.246.149.149/axis-media/media.amp?streamprofile=MedonMedium";
//String videoSrc ="http://root:root@134.246.149.149:8090/mjpg/video.mjpg";
try{
// MediaPlayer mp = MediaPlayer.create(this, Uri.parse(videoSrc));
//mp.start();
v.setVideoURI( Uri.parse(videoSrc) );
v.requestFocus();
pd = new ProgressDialog(MainActivity.this);
pd.setTitle("Chargement du flux video");
pd.setMessage("Chargement du flux video en cours...");
pd.setCancelable(false);
pd.setIndeterminate(true);
pd.show();
v.setOnErrorListener(new OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
pd.dismiss();
return false;
}
});
v.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
pd.dismiss();
v.start();
}
});
}catch(Exception x)
{
x.printStackTrace();
} |
Partager