问题:
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