MediaPlayer播放.mp3文件没有任何问题。但是在播放.rm文件时会通过异常进行归档。
代码:
try{
AssetFileDescriptor afd = getAssets().openFd("song.rm");
MediaPlayer player;
player = new MediaPlayer();
player.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength());
player.prepare();
player.start();
} catch(Exception e){
System.out.println("Exception while Playing: "+e);
}
例外:
01-30 16:42:11.126: E/MediaPlayer(1404): Unable to to create media player
01-30 16:42:11.126: I/System.out(1404): Exception while Playing : java.io.IOException: setDataSourceFD failed.: status=0x80000000
答案 0 :(得分:2)
RealMedia(.rm
)不是Android的supported media formats之一。
答案 1 :(得分:0)
您需要创建它。
public static MediaPlayer create (Context context, int resid)