In my application I am sending notification to show it on notification bar it works perfectly.
But it gives me error while playing custom sound for notification.
I have tried saving mid file in application folder with an without extension and set its Uri for notification sound.
- Code: Select all
notification.audioStreamType = AudioManager.STREAM_NOTIFICATION;
notification.sound = Uri.fromFile(new File("/data/data/../alert2"));
When notification send no sound played and I seen the error in Logcat as
08-24 18:16:29.260: ERROR/PlayerDriver(51): Command PLAYER_SET_DATA_SOURCE completed with an error or info PVMFErrNotSupported
08-24 18:16:29.260: ERROR/MediaPlayer(76): error (1, -4)
08-24 18:16:29.270: WARN/PlayerDriver(51): PVMFInfoErrorHandlingComplete
08-24 18:16:29.290: WARN/NotificationService(76): error loading sound for file:///data/data/../alert2
08-24 18:16:29.290: WARN/NotificationService(76): java.io.IOException: Prepare failed.: status=0x1
08-24 18:16:29.290: WARN/NotificationService(76): at android.media.MediaPlayer.prepare(Native Method)
08-24 18:16:29.290: WARN/NotificationService(76): at android.media.AsyncPlayer$Thread.run(AsyncPlayer.java:78)
While I make a MediaPlayer using resource file for playing it plays well.
While shows similar error if I create MediaPlayer using Uri.
How can I overcome to this problem? I want to set it to notification any how please help me.