在正常狀況的顯示信息(在ipad機型上) ide
12-03 13:49:33.484: E/VideoSizeListener(13194): Send MEDIA_SET_VIDEO_SIZE message.
12-03 13:49:33.484: E/VideoSizeListener(13194): width:640, height : 480
12-03 13:49:33.488: I/Get RATIO(13194): dw: 800, dh: 480
12-03 13:49:33.488: I/VIDEO_INFO(13194): mVideoWidth: 640, mVideoHeight: 480
12-03 13:49:33.488: I/RATIO(13194): dw: 640, dh: 480
12-03 13:49:33.496: E/mediaplayer(13194): surfaceChanged
12-03 13:49:33.496: E/mediaplayer(13194): width: 640, height: 480
12-03 13:49:33.519: D/AudioHardware(13121): AudioHardware pcm playback is exiting standby.
12-03 13:49:33.519: D/AudioHardware(13121): openPcmOut_l() mPcmOpenCnt: 0
12-03 13:49:33.597: E/(13121): SsbSipMfcDecExe: IOCTL_MFC_DEC_EXE failed(ret : -2005)
12-03 13:49:33.613: E/AwesomePlayer(13121): component name =OMX.SEC.AVC.Decoder
12-03 13:49:33.613: E/AwesomePlayer(13121): render width=640
12-03 13:49:33.613: E/AwesomePlayer(13121): render height=480
12-03 13:49:33.613: E/AwesomePlayer(13121): render decodedWidth=640
12-03 13:49:33.613: E/AwesomePlayer(13121): render decodedHeight=480
12-03 13:49:33.613: D/SEC_Overlay(200): overlay_createOverlay:IN w=640 h=480 format=272
12-03 13:49:33.613: D/SEC_Overlay(200): src width, height are changed [w= 640, h= 480]->[w=640, h= 480]
12-03 13:49:33.613: D/v4l2_utils(200): v4l2_overlay_init:: w=640 h=480
12-03 13:49:33.621: I/SEC_Overlay(200): Opened video1/fd=186/obj=00437e50/shm=185/size=4096
12-03 13:49:33.621: D/SEC_Overlay(200): dst width, height have changed [w= 640, h= 480] -> [w=640, h= 480]
12-03 13:49:33.621: I/SEC_Overlay(200): Postponing Stream Enable/1/0
12-03 13:49:33.621: E/SecHardwareRenderer(13121): mColorFormat == OMX_COLOR_FormatVendorStartUnused+1
12-03 13:49:33.621: E/AwesomePlayer(13121): retmote render=2130706433 code
在htc手機上 component
12-03 13:57:39.253: E/VideoSizeListener(446): Send MEDIA_SET_VIDEO_SIZE message.
12-03 13:57:39.253: E/VideoSizeListener(446): width:640, height : 480
12-03 13:57:39.253: D/MediaPlayer(446): start() in
12-03 13:57:39.253: D/MediaPlayer(446): [DLNA]Streaming path, should force enable DLNA if in mirror mode or have usage dongle
12-03 13:57:39.263: D/MediaPlayer(446): [DLNA]not in Mirror mode, check nearby ready dongle
12-03 13:57:39.263: D/MediaPlayer(446): [DLNA]startMirror in
12-03 13:57:39.263: D/MediaPlayer(446): [getReadyDongle] No ready to use dongle
12-03 13:57:39.263: D/MediaPlayer(446): [DLNA][startMirror] out no ready to use dongle
12-03 13:57:39.263: D/MediaPlayer(446): [DLNA]start() streaming do local playback
12-03 13:57:39.263: D/MediaPlayer(446): doStart() in
12-03 13:57:39.263: D/MediaPlayer(446): beats setting trigger in start
12-03 13:57:39.263: D/MediaPlayer(446): beats setting true
12-03 13:57:39.263: D/MediaPlayer(446): triggerBeatsLogo=true
12-03 13:57:39.273: D/MediaPlayer(446): doStart() out
12-03 13:57:39.273: D/MediaPlayer(446): [DLNA]start() streaming out
12-03 13:57:39.273: I/Get RATIO(446): dw: 800, dh: 480
12-03 13:57:39.273: I/VIDEO_INFO(446): mVideoWidth: 640, mVideoHeight: 480
12-03 13:57:39.273: I/RATIO(446): dw: 640, dh: 480
12-03 13:57:39.293: E/mediaplayer(446): surfaceChanged
12-03 13:57:39.293: E/mediaplayer(446): width: 640, height: 480
12-03 13:57:39.293: D/MediaPlayer(446): [DLNA]setDisplay orm
在MediaPlayer與SurcaceView播放視頻的時候,若是播放的視頻碼流有誤,使Media Server Died, 這時若是從新釋放MediaPlayer並建立,有時會出現 [SurfaceView] connect: already connected (cur=3, req=3) setVideoSurfaceTexture failed: -22這樣的錯誤(這是在htc上出現的)或者出現 E/MemoryHeapBase(13312): mmap(fd=21, size=0) failed (Invalid argument)(這是在ipad上出現的) 視頻
分析緣由應該是surfaceview佔用,與新建立的mediaplayer沒法正常關聯,須要從新建立surfaceview ip
可行方法 get
surfaceView.setVisibility(View.GONE); it
surfaceView.setVisibility(View.VISIBLE); io
這樣就能夠從新建立surfaceview,能夠恢復上面提示的錯誤,正常播放。 form
參考代碼
private void Replay() {
mediaPlayer.reset();
mediaPlayer.release();
mediaPlayer = null;
surfaceView.setVisibility(View.GONE);
mediaPlayer = new MediaPlayer();
mediaPlayer.setOnErrorListener(mErrorListener);
mediaPlayer.setOnPreparedListener(new PrepareListener(0));
mediaPlayer.setOnVideoSizeChangedListener(new VideoSizeListener());
mediaPlayer.setOnCompletionListener(mOnCompletionListener);
surfaceView.setVisibility(View.VISIBLE);
try {
if (mediaPlayer != null) {
mediaPlayer.reset();
handlerUI.sendEmptyMessageDelayed(HIDESURFACE, 100);
mediaPlayer.setDataSource(strUrl);
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDisplay(surfaceHolder);
mediaPlayer.prepareAsync();// 緩衝
}
} catch (Exception e) {
e.printStackTrace();
}
}