最近的开发用到了一个功能,需要播放http的在线mp3文件,用的是MediaPlayer类,开始的时候很爽,几行代码就ok,就是先setDataSource(url) 然后PrepareAsync/Prepare,在OnPreparedListener里面start(),在htc g2上跑得很好,很稳定,可是拿到moto XT800上的时候却总是播放失败,只有偶尔成功过,试过了Create方法 setDataSource(Context,Uri)方法,setAudioStreamType(AudioManager.STREAM_MUSIC)都不行,真是相当郁闷,用AsyncPlayer类也不行,出错信息一样,但是所有这些在g2上都可以,g2用过1.6的系统,2.2的系统,xt800是2.1u1系统,我们的产品必须要在xt800上使用,这都好几天了,翻遍了网络都没找到原因T_T,这可怎么办呢,大家帮忙看看吧,我把两次出错前的LogCat信息贴上来,每次都是Prepare不成功。10-12 20:43:27.668: DEBUG/dalvikvm(1276): GC freed 4423 objects / 271784 bytes in 204ms10-12 20:43:36.457: ERROR/MediaPlayer(5945): stop called in state 110-12 20:43:39.856: DEBUG/omx_interface(1166): TIOMXInterface: creating interface10-12 20:43:39.856: DEBUG/omx_interface(1166): Calling DLOPEN on OMX_CORE_LIBRARY (libOMX_Core.so)10-12 20:43:39.856: DEBUG/omx_interface(1166): DLOPEN SUCCEEDED (libOMX_Core.so)10-12 20:43:39.856: DEBUG/omx_interface(1166): TIOMXInterface: library lookup success10-12 20:43:39.872: DEBUG/TIOMX_CORE(1166): init count = 110-12 20:43:39.950: DEBUG/PlayerDriver(1166): setHttpDownloadFilename:url(http://zonehey.com/123.mp3)10-12 20:43:39.950: DEBUG/PlayerDriver(1166): setHttpDownloadFilename: retrieved ext(.mp3)10-12 20:43:39.950: DEBUG/PlayerDriver(1166): setHttpDownloadFilename: find ext(.mp3)10-12 20:43:39.950: DEBUG/PlayerDriver(1166): setHttpDownloadFilename: truncated filename (http://zonehey.com/123)10-12 20:43:39.957: DEBUG/PlayerDriver(1166): setHttpDownloadFilename: original filename (123.mp3)10-12 20:43:39.957: DEBUG/PlayerDriver(1166): setHttpDownloadFilename: replaced filename (/sdcard/download/123.mp3)10-12 20:43:40.700: INFO/hiker_palyer(5945): 010-12 20:43:47.872: VERBOSE/PVASFFFRecognizerPlugin(1166): PVASFFFRecognizerPlugin::Recognize10-12 20:43:47.879: VERBOSE/PVASFFFRecognizerPlugin(1166): trying to recognize asf file...10-12 20:43:47.879: VERBOSE/PVASFFFRecognizerPlugin(1166): recognize finished, isasffile = 010-12 20:43:47.879: VERBOSE/PVMKVFFRecognizerPlugin(1166): PVMKVFFRecognizerPlugin::Recognize10-12 20:43:47.879: VERBOSE/PVMKVFFRecognizerPlugin(1166): trying to recognize mkv file...10-12 20:43:47.887: VERBOSE/PVMKVFFRecognizerPlugin(1166): recognize finished, ismkvfile = 010-12 20:43:47.887: VERBOSE/PVAVIFFRecognizerPlugin(1166): PVAVIFFRecognizerPlugin::Recognize10-12 20:43:47.887: VERBOSE/PVAVIFFRecognizerPlugin(1166): trying to recognize avi file...10-12 20:43:47.887: VERBOSE/PVAVIFFRecognizerPlugin(1166): recognize finished, isavifile = 010-12 20:43:47.895: WARN/MediaPlayer(5945): info/warning (1, 26)10-12 20:43:47.895: INFO/MediaPlayer(5945): Info (1,26)10-12 20:43:47.911: ERROR/PlayerDriver(1166): Command PLAYER_INIT completed with an error or info PVMFErrCorrupt10-12 20:43:47.918: ERROR/MediaPlayer(5945): error (1, -10)10-12 20:43:47.918: ERROR/MediaPlayer(5945): Error (1,-10)10-12 20:43:47.918: WARN/PlayerDriver(1166): PVMFInfoErrorHandlingComplete10-12 20:43:47.918: INFO/hiker_palyer(5945): error110-12 20:43:47.918: INFO/hiker_palyer(5945): complete110-12 20:43:47.918: ERROR/MediaPlayer(5945): stop called in state 110-12 20:43:47.918: ERROR/MediaPlayer(5945): error (-38, 0)10-12 20:56:03.584: DEBUG/dalvikvm(1276): GC freed 1904 objects / 98944 bytes in 144ms10-12 20:56:06.412: DEBUG/MediaPlayer(6405): Couldn't open file on client side, trying server side10-12 20:56:06.428: DEBUG/omx_interface(1166): TIOMXInterface: creating interface10-12 20:56:06.428: DEBUG/omx_interface(1166): Calling DLOPEN on OMX_CORE_LIBRARY (libOMX_Core.so)10-12 20:56:06.428: DEBUG/omx_interface(1166): DLOPEN SUCCEEDED (libOMX_Core.so)10-12 20:56:06.428: DEBUG/omx_interface(1166): TIOMXInterface: library lookup success10-12 20:56:06.436: DEBUG/TIOMX_CORE(1166): init count = 110-12 20:56:06.475: DEBUG/PlayerDriver(1166): setHttpDownloadFilename:url(http://zonehey.com/123.mp3)10-12 20:56:06.475: DEBUG/PlayerDriver(1166): setHttpDownloadFilename: retrieved ext(.mp3)10-12 20:56:06.475: DEBUG/PlayerDriver(1166): setHttpDownloadFilename: find ext(.mp3)10-12 20:56:06.475: DEBUG/PlayerDriver(1166): setHttpDownloadFilename: truncated filename (http://zonehey.com/123)10-12 20:56:06.475: DEBUG/PlayerDriver(1166): setHttpDownloadFilename: original filename (123.mp3)10-12 20:56:06.475: DEBUG/PlayerDriver(1166): setHttpDownloadFilename: replaced filename (/sdcard/download/123.mp3)10-12 20:56:08.576: INFO/hiker_palyer(6405): 010-12 20:56:12.912: VERBOSE/PVASFFFRecognizerPlugin(1166): PVASFFFRecognizerPlugin::Recognize10-12 20:56:12.920: VERBOSE/PVASFFFRecognizerPlugin(1166): trying to recognize asf file...10-12 20:56:12.920: VERBOSE/PVASFFFRecognizerPlugin(1166): recognize finished, isasffile = 010-12 20:56:12.920: VERBOSE/PVMKVFFRecognizerPlugin(1166): PVMKVFFRecognizerPlugin::Recognize10-12 20:56:12.920: VERBOSE/PVMKVFFRecognizerPlugin(1166): trying to recognize mkv file...10-12 20:56:12.920: VERBOSE/PVMKVFFRecognizerPlugin(1166): recognize finished, ismkvfile = 010-12 20:56:12.920: VERBOSE/PVAVIFFRecognizerPlugin(1166): PVAVIFFRecognizerPlugin::Recognize10-12 20:56:12.920: VERBOSE/PVAVIFFRecognizerPlugin(1166): trying to recognize avi file...10-12 20:56:12.920: VERBOSE/PVAVIFFRecognizerPlugin(1166): recognize finished, isavifile = 010-12 20:56:12.928: WARN/MediaPlayer(6405): info/warning (1, 26)10-12 20:56:12.928: INFO/MediaPlayer(6405): Info (1,26)10-12 20:56:12.944: ERROR/PlayerDriver(1166): Command PLAYER_INIT completed with an error or info PVMFErrCorrupt10-12 20:56:12.944: ERROR/MediaPlayer(6405): error (1, -10)10-12 20:56:12.951: ERROR/MediaPlayer(6405): Error (1,-10)10-12 20:56:12.951: WARN/PlayerDriver(1166): PVMFInfoErrorHandlingComplete10-12 20:56:12.951: INFO/hiker_palyer(6405): error110-12 20:56:12.951: INFO/hiker_palyer(6405): complete110-12 20:56:12.951: ERROR/MediaPlayer(6405): stop called in state 110-12 20:56:12.951: ERROR/MediaPlayer(6405): error (-38, 0)

解决方案 »

  1.   

    你看看是不是音乐文件有问题导致prepare不成功,你用android自带的播放器播放同样的mp3文件看可以成功不
      

  2.   

    10-12 20:56:12.912: VERBOSE/PVASFFFRecognizerPlugin(1166): PVASFFFRecognizerPlugin::Recognize10-12 20:56:12.920: VERBOSE/PVASFFFRecognizerPlugin(1166): trying to recognize asf file...10-12 20:56:12.920: VERBOSE/PVASFFFRecognizerPlugin(1166): recognize finished, isasffile = 010-12 20:56:12.920: VERBOSE/PVMKVFFRecognizerPlugin(1166): PVMKVFFRecognizerPlugin::Recognize10-12 20:56:12.920: VERBOSE/PVMKVFFRecognizerPlugin(1166): trying to recognize mkv file...10-12 20:56:12.920: VERBOSE/PVMKVFFRecognizerPlugin(1166): recognize finished, ismkvfile = 010-12 20:56:12.920: VERBOSE/PVAVIFFRecognizerPlugin(1166): PVAVIFFRecognizerPlugin::Recognize10-12 20:56:12.920: VERBOSE/PVAVIFFRecognizerPlugin(1166): trying to recognize avi file...10-12 20:56:12.920: VERBOSE/PVAVIFFRecognizerPlugin(1166): recognize finished, isavifile = 0这几句不就说得很清楚了吗?。。认不出文件格式 各种is都是0
      

  3.   


    我也关注了这边,貌似是PVASFFFRecognizer没有识别出格式,当做视频文件对待了。但是我已经调用了setAudioStreamType(AudioManager.STREAM_MUSIC)方法,并且尝试了其他几种StreamType,同时代码在G2上跑相当稳定,却在xt800出问题。而且翻遍了MediaPlayer,并没有别的和文件格式类型相关的api了。
      

  4.   

    我想是不是应该找moto的硬件厂商咨询一下!感觉不是代码的问题,而是硬件驱动的问题!
      

  5.   

    有道理,
    moto用的android都是经过自定义改造的,和模拟器上及原版android机器上跑的效果就不一样。
      

  6.   

    既然播放本地文件没问题,那就不是硬件的问题了啊!播放有问题的文件是不是你从网络下载的?如果是你用其他播放器去播放那个下载的文件,怀疑下载时导致文件有问题了!goodluck
      

  7.   

    看LOG感觉就是底层Opencore文件节点处理的地方出错了。
       唉 , Media系统是有点伤脑筋哦 。
      

  8.   

    呵呵,看了一下log应该是没有设别到文件格式,就是说MOTO的机器上把人家opencore原来的那个播放http/rtsp流的识别组建给去掉了,就是libopencore_streamingreg.so,libpvrtspunicast_streamingreg.so libpvrtspunicast_streaming.so libpvrtsptunicast_streamingreg.so libpvrtsptunicast_streaming.so还有就是在pvcfg.cfg中加上这个,但是有可能还是需要该moto的
    opencore代码这个就难办了
      

  9.   

    看来这位仁兄对Opencore有一定的研究哦 ,呵 ,看你头像看出来了。
    嗯 ,以后多向你学习一下这个东西 。
      

  10.   

    感谢ls的各位的帮助了,找了moto他们坚持没问题,说在新版本机器测试可以,沟通很没效率,我也没话说了,自己太倒霉。