問題:
I was wondering how I could play a notification sound without playing it over the media stream. 我想知道如何在不通過媒體流播放通知聲音的情況下播放通知聲音。 Right now I can do this via the media player, however I don't want it to play as a media file, I want it to play as a notification or alert or ringtone. 現在,我可以通過媒體播放器來執行此操作,但是我不希望它作爲媒體文件播放,我希望它作爲通知或警報或鈴聲播放。 heres an example of what my code looks like right now: 這是我的代碼現在看起來像的一個示例:
MediaPlayer mp = new MediaPlayer();
mp.reset();
mp.setDataSource(notificationsPath+ (String) apptSounds.getSelectedItem());
mp.prepare();
mp.start();
解決方案:
參考一: https://en.stackoom.com/question/IdOQ參考二: https://stackoom.com/question/IdOQ