Volume change effect both AVPlayer and AudioServices - ios

I have both AVPlayer and AudioServices to play sound in my game.
I use AVPlayer for playing a background music which I do need to loop continuously, and I use AudioServices with soundID to play sound effects on button tap.
The problem is when I decrease the volume with iPhone side volume buttons it does affect on music play by AVPlayer but not on sounds which play with AudioServices.
What should I do to make them both play at the same volume and volume change affect on them both at same time?

Related

Playing short sound with SystemSound or AVAudioPlayer on iOS

Creating custom spinner for iOS and for each rotation change need to play sound. Sound itself is 0.5 sec. According to Apple's documentation I used SystemSound to play it but now I can't control volume with hardware buttons cause audio context is Volume(media) and as I understood SystemSound works in different context, Ringer.
I tried to use AVAudioPlayer but there is a small delay when sound is attaching to the player and this glitches UI(small delay so spinner doesn't rotate smoothly).
Any ideas how this can be solved ?
I was thinking about somehow programmaticaly change this context by triggering controls that are working with systemSound, but no luck.
EDITED:
I've made sure that have only 1 instance of AVAudioPlayer and didn;t stop playing sound but paused it and only after spinner finished rotating then stop and dispose, but still same result

AVAudioPlayer no sound when device is muted

How is the easiest way to program the AVAudioPlayer in the way that it is not playing music, while the device is muted(the physical slider on the left hand side is switched towards back of the phone)? It should just play music, if the device is unmuted.
you can have a slider that controls the volume for your AVAudioplayer, and an outlet for the slider that gets the value of the slider. When the slider value is set to zero that means when the volume is zero just use "youplayername.pause()" to pause the audio and when the volume is not zero, you can have two cases i.e. the audio is playing or the audio is paused. so you can set a boolean for condition of audio playing and code it accordingly. Use nested if else to achieve this result. I hope this answer helps you.

Play music in background and only stop in certain instances

I have an app that shows videos in a timeline. The videos autoplay and by default they should be silent. If the user is playing music in the background, music should not stop at this time. It is only when tapping the video that it should actually pause the background music and let the video play. And once the video is done playing, the user's previous audio should continue where it left off.
I've tried using
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];
but this lets the music mix with the audio even if the video is in full screen mode. Of course, I could ensure that when the play button is tapped, the music pauses, but that might not be the cleanest solution.
Any better ideas?

AIR for iOS Sound.play() stops background music

In the game I'm building there are sound effects and music. Players are able to turn off the in-game music and sound effects. I assume that when a player turns off the in-game music it's probably because they want to listen to their own music. However, when I run a Sound.play() in order to play a sound effect the background music being played from the music app is stopped. Is there a way around this?
Thanks in advance.

Stop the sound of a video without stoping the video

I have a video with sounds, and I want to play other sounds on the background. So I want to stop the video music to keep playing just the other music. I have to code for all except to stop the music for the video. Is it possible to build?

Resources