简体   繁体   English

使用MediaPlayer播放mp3文件

[英]Play mp3 file using MediaPlayer

When I use MediaPlayer to play mp3 file, the system will report error log: Prepare failed: status=0xFFFFFF8E . 当我使用MediaPlayer播放mp3文件时,系统将报告错误日志: Prepare failed: status=0xFFFFFF8E But the Realplayer is normal. 但是Realplayer是正常的。

I find that it has the error occurred only in higher ROM version. 我发现它只有在更高版本的ROM中才出现错误。 Like in the version4.0 it has the error. 像版本4.0中一样,它具有错误。 In version2.3 it has not the error. 在version2.3中,没有错误。

The code: 编码:

private MediaPlayer mpBack = null;
/**
 * read in background sound from the resource file 
 * @param resId
 */
public void MediaPlay(int resId){
if(!isPlaying()){
mpBack = MediaPlayer.create(ctMedia, resId);
/**Volume Set */
mpBack.setVolume(0.8f, 0.8f);   
/**Background music default infinite loop*/
mpBack.setLooping(true);    
mpBack.start();
}
}

LogCat error: LogCat错误:

12-18 21:51:57.380: E/MediaPlayer(31457): mOnVideoSizeChangedListener is null. Failed to send MEDIA_SET_VIDEO_SIZE message.

12-18 21:51:57.380: E/MediaPlayer(31457): mOnPreparedListener is null. Failed to send MEDIA_PREPARED message.

use 采用

mpBack.prepare();

before you start mediaplayer 在您开始Mediaplayer之前

尝试这个:

mpBack = new MediaPlayer().create(context, R.raw.blah);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM