UILocalNotification custom sound is not playing in iOS7

前端 未结 9 1580
别那么骄傲
别那么骄傲 2020-12-09 10:00

I\'m using UILocalNotification in an application.

In the application there are two sounds which are played conditionally- I have applied proper conditio

相关标签:
9条回答
  • 2020-12-09 10:21

    Did you try to turn off "Do not disturb" mode off? I have the same problem, then I found out "Do not Disturb" is on. After turn off that, it all works the right way.

    0 讨论(0)
  • 2020-12-09 10:23

    If mp3 file is edited with some tool, it is possible that something was missed by edit tool.

    I had similar problem while trying to play mp3 file as local notification sound. Sound was shorter than 30 seconds, it was bundled, everything appears regular on the surface. After few hours i have realised that problem was caused by online mp3 cutter tool. I have find better editor, and file became playable on notification.

    0 讨论(0)
  • 2020-12-09 10:23

    Make sure the sound is added to the main bundle!

    0 讨论(0)
  • 2020-12-09 10:24

    try using .caf file instead of .mp3

    afconvert -f caff -d LEI16@44100 -c 1 wolf.wav wolf_out.caf
    
    0 讨论(0)
  • 2020-12-09 10:36

    I didn't get any idea why it did work.

    But, at last I have solved my problem by making a new project in Xcode 5.0 and ported old project to this new project. So it's working and I can get sound too.

    0 讨论(0)
  • 2020-12-09 10:38

    I ran into the same issue, I had to do the following steps:

    1. Convert the file from mp3 or wav to caf. As stated in other answers you can convert wav, aif and mp3 files in terminal using the command:

      afconvert -f caff -d LEI16@44100 -c 1 in.mp3 out.caf

    2. You can also export with Quicktime 7 as .aif with the following settings Linear PCM Rate 44.100 Linear PCM sample size 16 these aif files seem to be supported.

    3. Make sure you files are less than 30 seconds, i.e 29 seconds or less.

    4. Add you files to the root of your bundle, you can drag drop into Xcode or right click "add files to (projectname)" Note you must select the following options: a)Destination Copy items if needed b)Add to targets (your build name(s)) 4)Reference the file by its name including the extension e.g notif.soundName = @"sound.caf";

    Make sure you delete the app from the device / simulator between tests or you will not see the results of your changes.

    If your still having problems, check the sound file file is in the root of the project. Check the Sound file "Target Membership" is selected in the show file inspector.

    0 讨论(0)
提交回复
热议问题