简体   繁体   中英

Strange sound when setting custom notification sound Android

I've setted the following code to play a custom MP3 sound:

notification.sound = Uri.parse("android.resource://nl.myapp.myappver/" + R.raw.mysound);

However on my HTC debug phone the sound doesn't play it plays a very weird tone. It's not the default tone because that sounds different. Logs

10-25 20:48:00.578: V/MediaPlayer(31528): setDataSource(android.resource://nl.myapp.myappver/2130968576)
10-25 20:48:00.578: V/MediaPlayerService(31483): setDataSource(android.resource://nl.myapp.myappver/2130968576)
10-25 20:48:00.578: V/MediaPlayerService(31483): getPlayerTypeFromMAP(android.resource://nl.myapp.myappver/2130968576): PLAYERS_MAP[18].playertype (UNKNOWN player_type code)0
10-25 20:48:00.578: I/AwesomePlayer(31483): setDataSource_l('android.resource://nl.myapp.myappver/2130968576')
10-25 20:48:02.380: D/HfmMessageReceiver(15434): receive ACTION_NOTIFICATION_SOUND_COMPLETE, pkg= nl.myapp.myappver, id= 920

What's the reason for my phone to play a different tone? The sound file is an MP3 file of +/- 4 seconds.

找到了答案,我不得不将文件另存为.ogg而不是.mp3,现在声音可以正常播放了!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM