我想使用此代码和vitamio lib
播放流视频当我运行此代码时,它会异常
这是代码
private void playVideo(String path) {
doCleanUp();
try {
if (path == "") {
// Tell the user to provide a media file URL.
Toast.makeText(
this,
"Please edit Your Path,"
+ " and set the path variable to your media file URL.",
Toast.LENGTH_LONG).show();
return;
} else {
// Create a new media player and set the listeners
mMediaPlayer = new MediaPlayer(this);
mMediaPlayer.setDataSource(path);
mMediaPlayer.setDisplay(holder);
mMediaPlayer.prepareAsync();
mMediaPlayer.setOnBufferingUpdateListener(this);
mMediaPlayer.setOnCompletionListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnVideoSizeChangedListener(this);
setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
} catch (Exception e) {
Log.i(TAG, "PlayVideoException");
Log.e(TAG, "error: " + e.getMessage(), e);
// Toast.makeText(this, "sorry", Toast.LENGTH_LONG).show();
}
}
public void onBufferingUpdate(MediaPlayer arg0, int percent) {
// Log.d(TAG, "onBufferingUpdate percent:" + percent);
}
public long getCurrentPosition() {
return mMediaPlayer.getCurrentPosition();
}
public long getDuration() {
return mMediaPlayer.getDuration();
}
public boolean onError(MediaPlayer mp, int whatError, int extra) {
if (whatError == MediaPlayer.MEDIA_ERROR_IO) {
Log.v(TAG, "Media Error, Server Died " + extra);
} else if (whatError == MediaPlayer.MEDIA_ERROR_UNKNOWN) {
Log.v(TAG, "Media Error, Error Unknown " + extra);
}
isVideoError = true;
return false;
}
public void onCompletion(MediaPlayer arg0) {
onComplete = true;
Log.d(TAG, "onCompletion called");
Log.i(TAG, "onCompletion called");
}
public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
Log.v(TAG, "onVideoSizeChanged called");
if (width == 0 || height == 0) {
Log.e(TAG, "invalid video width(" + width + ") or height(" + height
+ ")");
return;
}
mIsVideoSizeKnown = true;
mVideoWidth = width;
mVideoHeight = height;
if (mIsVideoReadyToBePlayed && mIsVideoSizeKnown) {
startVideoPlayback();
}
}
public void onPrepared(MediaPlayer mediaplayer) {
Log.d(TAG, "onPrepared called");
mIsVideoReadyToBePlayed = true;
if (mIsVideoReadyToBePlayed && mIsVideoSizeKnown) {
startVideoPlayback();
}
}
public void surfaceChanged(SurfaceHolder surfaceholder, int i, int j, int k) {
Log.d(TAG, "surfaceChanged called");
}
public void surfaceDestroyed(SurfaceHolder surfaceholder) {
Log.d(TAG, "surfaceDestroyed called");
}
public void surfaceCreated(SurfaceHolder holder) {
Log.d(TAG, "surfaceCreated called");
try {
doTimerTaskforVideo();
} catch (Exception e) {
Log.d(TAG, "surfaceCreated created Exception");
}
}
@Override
protected void onPause() {
super.onPause();
releaseMediaPlayer();
doCleanUp();
}
@Override
protected void onDestroy() {
super.onDestroy();
TRS.RssTimer.cancel();
VideoTimer.cancel();
XMLTimer.cancel();
surfaceDestroyed(holder);
releaseMediaPlayer();
mMediaPlayer = null;
doCleanUp();
}
private void releaseMediaPlayer() {
if (mMediaPlayer != null) {
mMediaPlayer.release();
mMediaPlayer = null;
}
}
private void doCleanUp() {
mVideoWidth = 0;
mVideoHeight = 0;
mIsVideoReadyToBePlayed = false;
mIsVideoSizeKnown = false;
}
private void startVideoPlayback() {
Log.v(TAG, "startVideoPlayback");
holder.setFixedSize(mVideoWidth, mVideoHeight);
mMediaPlayer.start();
}
,例外是:
05-17 20:17:55.715: E/dalvikvm(21042): threadid=17: native thread exited without detaching
05-17 20:17:55.715: E/dalvikvm(21042): VM aborting
05-17 20:17:55.715: A/libc(21042): Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 21543 (helnix.signage)
如何确定导致该异常的线程以及如何防止此异常
在同一个项目中现在显示此异常
05-18 16:58:44.080: E/Vitamio[4.2.1][Player](4327): stop called in state 4
提前致谢