我一直在尝试使用 SoundPool 播放默认铃声,但没有成功。在下面的代码中
String ringtone = Settings.System.DEFAULT_RINGTONE_URI.getPath();
SoundPool ringPhone = new SoundPool(2, AudioManager.STREAM_RING, 1);
int soundID = ringPhone.load(Settings.System.DEFAULT_RINGTONE_URI.getPath(), 1);
int soundID = ringPhone.load(ringtone, 1);
ringPhone.play(soundID, 0.99f, 0.99f, 1, 0, 1);
我收到消息“加载内容时出错 /system/ringtone sample 0 not READY”。将 URI 替换为 sd 卡上现有 mp3 文件的硬路径会产生类似的结果。
我究竟做错了什么?谢谢,
凯尔