gpt4 book ai didi

android - Vitamio Bug播放本地音频

转载 作者:行者123 更新时间:2023-12-03 02:13:29 25 4
gpt4 key购买 nike

我正在成功使用Vitamio bundle 包传输音频,但是在某些情况下,我必须播放本地音频。在 MediaPlayerDemo_Audio Activity 中,代码表示在这种情况下,如果您要播放音频,则存在一个错误:

            case RESOURCES_AUDIO:
/**
* TODO: Upload a audio file to res/raw folder and provide its resid in
* MediaPlayer.create() method.
*/
//Bug need fixed
mMediaPlayer = createMediaPlayer(this, R.raw.test_cbr);
mMediaPlayer.start();

}
public MediaPlayer createMediaPlayer(Context context, int resid) {
try {
AssetFileDescriptor afd = context.getResources().openRawResourceFd(resid);
MediaPlayer mp = new MediaPlayer(context);
mp.setDataSource(afd.getFileDescriptor());
afd.close();
mp.prepare();
return mp;
} catch (IOException ex) {
Log.d(TAG, "create failed:", ex);
// fall through
} catch (IllegalArgumentException ex) {
Log.d(TAG, "create failed:", ex);
// fall through
} catch (SecurityException ex) {
Log.d(TAG, "create failed:", ex);
// fall through
}
return null;
}

执行mMediaplayer.prepare()方法并且两个都不存在Mediaplayer.create()方法时,createMediaPlayer方法崩溃,所以...我该怎么办?提前Thx

最佳答案

尝试在 list 中添加此权限

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

关于android - Vitamio Bug播放本地音频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22131561/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com