代码语言:javascript
复制rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov
代码语言:javascript
复制 if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
代码语言:javascript
复制private void PlayVideo() {
new Thread() {
public void run() {
try {
player.setDataSource(MonitorActivity.this, Uri.parse(stream_url));
sh = sfv.getHolder();
sh.addCallback(new MyCallBack());
player.prepare();
player.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
handler.sendEmptyMessage(DOWNLOAD_SUCCESS);
player.start();
player.setLooping(true);
}
});
} catch (Exception e) {
handler.sendEmptyMessage(DOWNLOAD_FAILED);
Log.e("MonitorActivity", e.getMessage() "摄像头未开启或网络异常");
e.printStackTrace();
}
}
}.start();
}
代码语言:javascript
复制@Override
protected void onDestroy() {
if(player.isPlaying()){
player.stop();//停止音频的播放
}
player.release();//释放资源
super.onDestroy();
}