我有问题,为我的游戏加载声音。或者更确切地说,是一些声音。加载R.raw.success
和R.raw.fail
似乎没有问题。但所有的笔记都不会被载入。以下是我的加载代码:
SoundPool soundPool = new SoundPool(20, AudioManager.STREAM_MUSIC, 1);
int[] sounds = new int[6];
sounds[0] = soundPool.load(getApplicationContext(), R.raw.note_c, 1);
sounds[1] = soundPool.load(getApplicationContext(), R.raw.note_d, 1);
sounds[2] = soundPool.load(getApplicationContext(), R.raw.note_e, 1);
sounds[3] = soundPool.load(getApplicationContext(), R.raw.note_g, 1);
sounds[4] = soundPool.load(getApplicationContext(), R.raw.note_a, 1);
sounds[5] = soundPool.load(getApplicationContext(), R.raw.note_ctwo, 1);
success_sound = soundPool.load(getApplicationContext(), R.raw.success, 1);
fail_sound = soundPool.load(getApplicationContext(), R.raw.fail, 1);
我加载文件的顺序似乎并不重要。只加载fail
和success
,没有问题。声音工作了一段时间,但是在我处理的最后一个补丁中,声音停止了加载。更改文件名也不能解决这一问题。
已经广泛地尝试了“谷歌搜索”各种形式的错误,但都没有用。我在LogCat中得到了以下输出:(最后两行是加载成功和失败的声音,没有问题。)
com.example.application E/WVMExtractor: Failed to open libwvm.so: dlopen failed: library "libwvm.so" not found
com.example.application E/NdkMediaExtractor: sf error code: -1010
com.example.application E/SoundPool: Unable to load sample
com.example.application E/NdkMediaExtractor: sf error code: -1010
com.example.application E/SoundPool: Unable to load sample
com.example.application E/NdkMediaExtractor: sf error code: -1010
com.example.application E/SoundPool: Unable to load sample
com.example.application E/NdkMediaExtractor: sf error code: -1010
com.example.application E/SoundPool: Unable to load sample
com.example.application E/NdkMediaExtractor: sf error code: -1010
com.example.application E/SoundPool: Unable to load sample
com.example.application E/NdkMediaExtractor: sf error code: -1010
com.example.application E/SoundPool: Unable to load sample
com.example.application I/OMXClient: Using client-side OMX mux.
com.example.application I/OMXClient: Using client-side OMX mux.
当声音是假定要播放的时,我得到以下输出:
W/SoundPool: sample 1 not READY
发布于 2017-03-07 14:13:16
问题可能在于你的资产(音频文件)。
对于LG E/NdkMediaExtractor: sf error code: -1010
设备上的一些视频文件(.mov),我也有同样的问题(.mov)。(三星S7、华为P9等设备没有问题)
在将所有文件转换为:
for f in *.mov; do ffmpeg -i "$f" -c copy -movflags +faststart "${f%.mov}.mp4"; done
视频文件被正确加载到任何地方。
所以,我对你的建议是:尝试播放你的音频文件格式--把它们转换成其他的格式可能会有帮助。
https://stackoverflow.com/questions/39297363
复制相似问题