我正在尝试循环播放 mp4 视频,但我的两台设备有问题(在所有其他设备上我的代码工作正常)Motorola Defy 2.2.1和Motorola Atrix 4G 2.3。
问题是在一次运行后媒体卡住了,我收到了这个错误:
08-12 17:04:15.031: W/MediaPlayer(4710): info/warning (1, 44)
08-12 17:04:15.031: I/MediaPlayer(4710): Info (1,44)
08-12 17:04:15.031: D/MediaPlayer(4710): getMetadata
08-12 17:04:30.742: W/AudioSystem(4710): AudioFlinger server died!
08-12 17:04:30.742: W/IMediaDeathNotifier(4710): media server died
08-12 17:04:30.742: E/MediaPlayer(4710): error (100, 0)
08-12 17:04:30.742: W/AudioSystem(4710): AudioPolicyService server died!
08-12 17:04:30.750: E/MediaPlayer(4710): Error (100,0)
08-12 17:04:30.750: D/VideoView(4710): Error: 100,0
08-12 17:04:30.750: E/MediaPlayer(4710): stop called in state 0
08-12 17:04:30.750: E/MediaPlayer(4710): error (-38, 0)
08-12 17:04:30.750: W/MediaPlayer(4710): mediaplayer went away with unhandled events
08-12 17:04:59.711: D/dalvikvm(4710): GC_FOR_MALLOC freed 9260 objects / 742128 bytes in 80ms
这是我的代码:
protected void prepareVideoView(File video, String clipId) {
// final Activity currentView = this;
final VideoView vv = (VideoView) findViewById(R.id.video);
vv.setOnErrorListener(Library_callHandler.getErrorHandler(video));
vv.setVideoPath(video.getAbsolutePath());
vv.setVisibility(View.VISIBLE);
vv.setVerticalScrollBarEnabled(false);
vv.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
try {
int counter = 0;
while (vv.isPlaying() && counter++ < 3) {
try {
Thread.currentThread();
Thread.sleep(100);
} catch (InterruptedException ignore) {
}
}
if (vv.isPlaying()) {
com.vringo.shared.Log
.log(com.vringo.shared.Log.LEVEL_INFO,
"VmcRingerActivity onCompletion vv.isPlaying()--> finish()");
finishInstance();
return;
}
vv.start();
} catch (IllegalStateException e) {
// ResidentService.restoreRinger(currentView);
}
}
});
vv.start();
Library_callHandler.track_info("CLIP_RINGTONE", clipId);
// - tracker.trackEvent(VringoConstants.CAT_CLIPS,
// VringoConstants.ACT_PLAY_RINGER,
// String.valueOf(videoClip.getClipId()), 0);
// - tracker.dispatch();
// Library_callHandler.info("Ringer video playback started.");
}