`
univasity
  • 浏览: 816090 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

[多媒体]关于MediaPlayer中的错误代码(update)[整理]

阅读更多

开发中使用MediaPlayer时经常会遇到如下这样的错误提示(红色字):



 
但是API文档中并未找到详细说明或给出对应的错误列表...

经过研究和网上资料的收集,暂总结如下:
error(-38, 0) 为例,
1. error中的两个数值,分别对应OnErrorListener.onError(MediaPlayer mp, int what, int extra)中的what (-38 )和extra (0 );
2. 对应编号的错误信息可以在这里 找到个大概说明,像这里的
  /*
   * DRM clock is not available or cannot be read
   */
   const PVMFStatus PVMFErrDrmClockError = (-38);
  /*
   * Return code for pending completion
   */
   const PVMFStatus PVMFPending = 0;

仍未知具体针对性的解决办法,但作为补救的方法(仅供参考):
通过设置监听器,并自己设置变量来标记MediaPlayer的大概状态(特别是Error,End,Idle),在操作相关的函数前先检测下,就能避免大多数"操作错误"。再不行就每个MediaPlayer的函数操作都加上对IllegalStateException异常的捕获。

ps:state 的对应表仍然不是很清楚,也许研究下源码能找到答案?

****** update ******* // 2011.03.29
通过源码找到了state 的相关定义:
enum media_player_states {
    MEDIA_PLAYER_STATE_ERROR              = 0,
    MEDIA_PLAYER_IDLE                             = 1 << 0, // 1
    MEDIA_PLAYER_INITIALIZED                 = 1 << 1, // 2
    MEDIA_PLAYER_PREPARING                  = 1 << 2, // 4
    MEDIA_PLAYER_PREPARED                    = 1 << 3, // 6
    MEDIA_PLAYER_STARTED                       = 1 << 4, // 8
    MEDIA_PLAYER_PAUSED                        = 1 << 5, // 16
    MEDIA_PLAYER_STOPPED                      = 1 << 6, // 32
    MEDIA_PLAYER_PLAYBACK_COMPLETE  = 1 << 7 // 64
};

---------------------------------------------------
参考连接:
  • 大小: 14.8 KB
分享到:
评论
3 楼 faithmy509 2013-05-02  
1<<3,1左移3位是8吧?
2 楼 univasity 2013-05-01  
faithmy509 写道
MEDIA_PLAYER_PREPARED                    = 1 << 3, // 6
笔误吧?

抱歉...我还没看出错误呢...望指正~
1 楼 faithmy509 2013-04-30  
MEDIA_PLAYER_PREPARED                    = 1 << 3, // 6
笔误吧?

相关推荐

Global site tag (gtag.js) - Google Analytics