MediaPlayer无法准备?

时间:2012-02-21 04:13:43

标签: android android-mediaplayer

我写了一个功能相当基本的流媒体广播应用,但有些设备拒绝“准备”,例如我的Optimus One运行2.2。我的应用程序在其他2.2设备上运行,任何我兄弟的S2运行2.3和我的Prime运行4.0.3。

知道为什么我的具体设计不会准备音频吗?

编辑:在

下面添加了一些代码
private void togglePlay() {
    try {
        if(!this.player.isPlaying()) {
            this.player.setAudioStreamType(AudioManager.STREAM_MUSIC);
            this.player.setDataSource(this.address);
            this.player.prepareAsync();
        } else {
            this.player.reset();
        }
    } catch (IllegalArgumentException e) {
        ;
    } catch (IllegalStateException e) {
        ;
    } catch (IOException e) {
        ;
    }
}

编辑:添加了ADB日志

03-09 08:17:26.933: I/ActivityManager(1352): Starting activity: Intent { cmp=com.landonmanning.mediaplayer.celestiaradio/.Media }
03-09 08:17:27.003: V/PVPlayer(1281): PVPlayer constructor
03-09 08:17:27.003: V/PVPlayer(1281): construct PlayerDriver
03-09 08:17:27.003: V/PlayerDriver(1281): constructor
03-09 08:17:27.013: V/PlayerDriver(1281): OpenCore hardware module loaded
03-09 08:17:27.013: V/PlayerDriver(1281): start player thread
03-09 08:17:27.023: V/PlayerDriver(1281): startPlayerThread
03-09 08:17:27.023: V/PlayerDriver(1281): InitializeForThread
03-09 08:17:27.023: V/PlayerDriver(1281): OMX_MasterInit
03-09 08:17:27.043: V/PlayerDriver(1281): OsclScheduler::Init
03-09 08:17:27.043: V/PlayerDriver(1281): CreatePlayer
03-09 08:17:27.083: V/PlayerDriver(1281): AddToScheduler
03-09 08:17:27.083: V/PlayerDriver(1281): PendForExec
03-09 08:17:27.083: V/PlayerDriver(1281): OsclActiveScheduler::Current
03-09 08:17:27.083: V/PlayerDriver(1281): StartScheduler
03-09 08:17:27.093: V/PVPlayer(1281): send PLAYER_SETUP
03-09 08:17:27.093: V/PlayerDriver(1281): Send player code: 2
03-09 08:17:27.093: V/PlayerDriver(1281): CommandCompleted
03-09 08:17:27.093: V/PlayerDriver(1281): Completed command PLAYER_SETUP status=PVMFSuccess
03-09 08:17:27.093: V/PVPlayer(1281): setDataSource(http://molestia.ponify.me:8062)
03-09 08:17:27.093: V/PVPlayer(1281): prepareAsync
03-09 08:17:27.093: V/PVPlayer(1281):   data source = http://molestia.ponify.me:8062
03-09 08:17:27.103: V/PlayerDriver(1281): Send player code: 3
03-09 08:17:27.103: V/PlayerDriver(1281): handleSetDataSource
03-09 08:17:27.103: V/PlayerDriver(1281): handleSetDataSource- scanning for extension
03-09 08:17:27.193: V/PlayerDriver(1281): CommandCompleted
03-09 08:17:27.193: V/PlayerDriver(1281): Completed command PLAYER_SET_DATA_SOURCE status=PVMFSuccess
03-09 08:17:27.193: V/PVPlayer(1281): run_init s=0, cancelled=0
03-09 08:17:27.193: V/PlayerDriver(1281): Send player code: 6
03-09 08:17:27.193: V/PlayerDriver(1281): release string is 2.2 len 3
03-09 08:17:27.453: D/StatusBarPolicy(1352): [BRIGHTHY] 0. mDataNetType: 3
03-09 08:17:27.453: D/StatusBarPolicy(1352): [BRIGHTHY] curNetwork=302220 curHPLMN=302220
03-09 08:17:27.903: I/ActivityManager(1352): Displayed activity com.landonmanning.mediaplayer.celestiaradio/.Media: 951 ms (total 4183 ms)
03-09 08:17:28.123: V/PlayerDriver(1281): HandleInformationalEvent: PVMFInfoErrorHandlingStart
03-09 08:17:28.123: V/PlayerDriver(1281): HandleInformationalEvent: type=26 UNHANDLED
03-09 08:17:28.123: W/MediaPlayer(20004): info/warning (1, 26)
03-09 08:17:28.123: I/MediaPlayer(20004): Info (1,26)
03-09 08:17:28.133: V/PlayerDriver(1281): CommandCompleted
03-09 08:17:28.133: V/PlayerDriver(1281): Completed command PLAYER_INIT status=PVMFFailure
03-09 08:17:28.133: E/PlayerDriver(1281): Command PLAYER_INIT completed with an error or info PVMFFailure, -1
03-09 08:17:28.133: E/MediaPlayer(20004): error (1, -1)
03-09 08:17:28.133: E/MediaPlayer(20004): Error (1,-1)
03-09 08:17:28.133: V/PVPlayer(1281): run_set_video_surface s=-2147483648, cancelled=0
03-09 08:17:28.133: V/PlayerDriver(1281): HandleInformationalEvent: PVMFInfoErrorHandlingComplete
03-09 08:17:28.133: W/PlayerDriver(1281): PVMFInfoErrorHandlingComplete

3 个答案:

答案 0 :(得分:0)

您需要先放置一个release()。由于多个媒体播放器实例,它可能会崩溃。

答案 1 :(得分:0)

日志中有趣的一行是:

Command PLAYER_INIT completed with an error or info PVMFFailure, -1

这是你的错误代码-1,遗憾的是它完全是通用的...它没有特别的意义。幸运的是,名称PVMFFailure是合适的Googlable ......它从链接的线程看起来媒体格式可能是可疑的。较旧的平台可能无法处理与较新平台相同的比特率和格式。

https://groups.google.com/forum/?fromgroups#!topic/android-developers/6uGbh37bVEQ

答案 2 :(得分:0)

我刚刚在手机上刷了CyanogenMod 7,现在我的应用效果很好。显然LG是迟钝的,喜欢破坏东西。仍然不确定为什么其他应用程序可以正常工作而我的工作没有,但我只需要在我的应用程序描述中添加一个注释,向其他LG用户解释该问题。