Is it possible play the user's selected ringtone or notification sound using AVAudioPlayer?
I've read we can play systems sounds using AudioServicesPlaySystemSound, like AudioServicesPlaySystemSound(1003), but I really need to play the sounds the user has selected as the ringtone or as notification or alarm sounds.
In Android this is possible using the following:
RingtoneManager.TYPE_ALARM
RingtoneManager.TYPE_NOTIFICATION
RingtoneManager.TYPE_RINGTONE
Is this possible in iOS 10 and above?
Related
I have a question about the AVAudioPlayer and its AVAudioSessionCategory parameter.
So, basically, I have a video chat between two users and I want to play music as a background for them. I tried to use the "AVAudioSessionCategoryPlayAndRecord" value for the AVAudioSessionCategory, but in that case, the music will be recorded and send together with the voice to the partner.
I think that I'm looking for a way to play music but do not record it, so each partner will be listening to its own music.
I am working on app and there I need to play sound when there is FCM notification.
I know I can play custom sound and I can play system sound(iOS). see below for code to play system sound
AudioServicesPlaySystemSound(1003);
I have seen this link and this link but nothing is what I want.
What I want:
I want that When the fcm notification come, I want to play the message/Notification sound that has been selected by user as default notification/message sounds. Also if the device is on silent it should not ring in this condition
NOTE: I know we can send sound name in FCM payload and add similar sound file in bundle But I really want to play sound that has been selected by user.
Please help me. I am right now helpless to play that sound.
I want to set a music which is longer than 30sec as notification soound. But after searching about this I came to know that it is not possible to add these type of music as notification sound. notification sound must be in 30sec longer otherwise it will not play music. Now how can I add more than 30sec longer music as notification sound?
I had a similar issue for my alarm app as well. What I did was a workaround when your app is in background. You play a music file in your code in background and increase the volume of the device to maximum. You can play as much longer music file as you want. Stop playing the music when someone clicks on the notification.
The only problem with this is that your app should not be killed or terminated.
I'm building a VoIP app on iOS and I'm using the AVAudioSession category of AVAudioSessionCategoryPlayAndRecord, which is recommended for VoIP apps that need to constantly play and record audio.
However, when the user switches their iPhone ringer to silent mode, the VoIP application will still play sound for an incoming call. This is not desired behavior.
Is there a way to prevent the incoming calls from playing audio when the user has their phone on silent, but still allow them to answer the call and have audio resume?
If you take a look here at the docs for AVAudioSession Categories, you can see that AVAudioSessionCategoryPlayAndRecord unfortunately does not obey the silencing of a phone, as seen below:
Your audio continues with the Silent switch set to silent and with the screen locked. (The switch is called the Ring/Silent switch on iPhone.)
If you want the audio to stop when you turn the phone to silent, you should use AVAudioSessionCategoryAmbient.
I think I found a solution that works for a VoIP application. If the phone is set to silent, I wanted the phone to show an alert and vibrate instead of playing the audible ring.
I can solve this by using local notifications and moving the sound out of the application and adding it to the notification itself. By specifying a sound file as part of the notification, iOS will handle whether it should play the audio or vibrate the phone. This is determined by the position of the Ring/Silent switch on the side of the phone.
Here's an Apple article on adding a sound to a local notification.
I am working on an Alarm app and i used AVAudioPlayer to play the alarm Sound, I have a slider to adjust the audioPlayer Sound in my application settings.Now when the alarm is making any sound i dont want to reduce/increase the audioPlayer Sound through the volume Keys of Iphone/Ipad.
//to set the slider value as player sound in my app
player.volume =[[NSUserDefaults standardUserDefaults]floatForKey:#"Volume"];
can anybody please suggest me on how to make the volume keys to show no effect on player Sound when the alarm is playing sound.
Thanks.
You should not change the default behavior of any device functionality. Apple won't approve the application as per my experience.