IOS - Accessing Audio Stream from Ipod, Pausing and Changing Volume - ios

I am working on an app that needs to pause and unpause the audio stream coming from the ipod app. Is there any way to do that? I want to make a button that once you press it, it pauses the currently playing song on the ipod app. Pressing it again unpauses where the music left off. I am also working on a way to change the volume of the ipod app, is there anyway to do this that does not rely on the user manually moving a slider?
Any help at all would be great. Thanks!

you could use this framework if you want: Media Player Framework
Specially the MPMusicPlayerController Class
You have this:
Controlling Playback
– play
– pause
– stop
Managing Playback Mode and State
volume ( property )

Related

UIWebView Keep Video Playing After Exiting Fullscreen

In our app, we want to be able to keep a video playing after the user has quit fullscreen mode. The video is a YouTube one, thus it uses YTPlayerView framework, which uses UIWebView and iframe player to play the video.
As you have probably noticed, in iOS 11, when a web video enters fullscreen, there is only one 'X' button at the upper left corner to quit fullscreen and pause the video, instead of two(one 'Done' at the top and one arrow at the bottom) like before.
I have been able to get a UIWindowDidBecomeHidden notification when the fullscreen quits, and play the video programmatically, but then I realize that if the user has already paused the video manually before quitting fullscreen, it will start playing nonetheless when he/she quits. However, adding something in the YTPlayerDelegate won't do much since the system will pause the video(sending the stateDidChange delegate) before sending the notification, so I cannot differentiate between a manual pause when fullscreen and a system pause when quitting fullscreen.
My question is, is there a way to detect leaving fullscreen action before the system pauses the video? If not, is there a native API to have the player keep playing? If not either, is this feature possible? How would I achieve it? Thanks.

I don't want play game music if system sound is already playing

I'm developing a game app which is having background music. but I don't want to play background music of game if system sound is already playing.Please help me.
All the user has to do is flip the switch on the side of the device (silent mode). Music will keep playing but app sounds will will be disabled.

Phonegap media stops system music

Phonegap media play method has a magic option playAudioWhenScreenIsLocked = false that does good job:
Prevents app music from playing when app is in background;
Makes app music obey the hardware "mute" button: without this option your app will ignore if user device is muted and play sound anyway.
But there is third hidden magic in this option. It stops current playing song from native Music app. Most of all it's annoying when I want to play short single sound.
Actually I would like to implement this scenario:
Music: Check if system music is playing on the app start. If it is not, play my app music, otherwise let user enjoy his own media.
Sound FX: Just play my little sound once and don't spoil anything.
And never play anything in background and when device is muted! Even if system Music app can let itself do so.
Has anyone managed to do something similar?
Thank you.
Ended up using https://github.com/floatinghotpot/cordova-plugin-nativeaudio (https://build.phonegap.com/plugins/2291)
Be aware: simple sound effects are not working in Simulator.

Preventing my app's audio from interfering with other background music

I think what I'm looking for is the combination of existing settings that I can't quite put together in the right order. I have an app that plays sound clips using AVAudioPlayer. There is a start/stop button.
I would like any other apps' audio to continue until my app actually needs to play something.
When my app is launched with some iTunes music playing, that music continues correctly. When I press play in my app, the other audio correctly stops, and my app plays. I stop my player, switch back to the music app, and press play again. But now when I switch back to my own app, the music stops immediately.
I would like it to again wait until it needs to play something before killing the music app.
My best guess is that once I've used the player, it is in some kind of 'I need audio' state, and remains in that state. How do I resign this state?

How to continue playing a youtube video at background when switch from my app back to home screen

Seems the default action for iOS 6 is to stop the video from playing after I switch to HOME screen. Then if I want to listen to the audio I have to go back to the app and press the 'Play' button again. I am using youtube API.
How can I continue playing the video when the application is in UIApplicationStateInactive and UIApplicationStateBackground. I just want to be able to listen to the audio even if I am on HOME screen or the screen is locked. Should I use a background thread or restart playing the video at the previous position as it was before turning the app inactive?
Take a look at the app 'Jasmine'. They managed to do something similar to what you are seeking. However, UIApplicationStateInactive/UIApplicationStateBackground will cause the video to pause. Double tapping the home button and then pressing the audio play button will cause the video's audio to resume without keeping the app active.
Take a look at the new iOS 7. You may have some luck there.
Inter-App Audio
Now your apps can make beautiful music together. With Inter-App Audio,
apps can register their audio streams to share with other apps. For
example, a series of apps could publish audio streams of instrument
tracks while another uses the combination of these streams to compose
a song. Inter-App Audio also provides for MIDI control of audio
rendering, remotely launching other registered Inter-App Audio apps
and more.

Resources