How to play audio file from raw/assets folder on the native/default media player?

后端 未结 4 1694
野的像风
野的像风 2020-12-03 20:43

I know i can play an mp3 file in the media player like that:

Intent intent = new Intent();  
intent.setAction(android.content.Intent.ACTION_VIEW);  
File fil         


        
4条回答
  •  抹茶落季
    2020-12-03 21:18

    If you just need to set the sound URI on the Notification.Builder, use

     Uri.parse("android.resource://com.my.great.application/"
                            + R.raw.mysound);
    

    where R.raw.mysound can be something like mysoud.ogg in the raw resources folder.

    However I am not sure if MP3 is exactly supported. As these are just internal resources of your application, try to convert to OGG.

提交回复
热议问题