swith on/off sound on iphone ( phoneGap + construct 2 ) - ios

i have done a game using construct 2, this game is called in an iframe in a JqueryMobile page.
my problem is that sometime when i click 'back button' some sound still played ( sounds are not a background sound but FX and are in queu so i cant stop theme with construct 2 pause function ).
my solution is to set sound off on iphone, but according this post, i have to use private api and that mean a rejected app.
have you a solution for this ?
thank you.

Construct 2 automatically pauses audio when the app is 'suspended' (in an invisible tab in a browser, or moved to the background as a mobile app). However I guess an iframe in a PhoneGap app doesn't fire the right events.
You can call them yourself, though: call these functions in the iframe to pause and resume the entire game (which includes audio):
cr_setSuspended(true); // pause game and mute audio
cr_setSuspended(false); // resume game and unmute audio

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.

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.

Pause / Play background audio from other apps

I know this is likely way outside of the sandbox but I thought I'd ask anyway:
I want to put a "pause / play" button in my app that will pause or play any background audio. Basically I'm looking to implement the play/pause button found in the multi-task bar.
A simple example is someone stars music with Pandora app, then launches my app. Is it possible to pause the background audio and resume it?
As a curiosity I have wondered if there was a way to create or broadcast the "remote control" events. Can I publish a pause/play event to the OS, perhaps?
I think here's what you're looking for. The trick is to loop a short audio file with silence when you want the other audio to stop. Then tell the iOS audio system when you're done, as suggested in the link.

iOS: background play from the browser?

Some iOS apps like Pandora continue playing audio after the app screen has been exited, and even after the device has been locked.
Is it possible to keep audio playing in this way from a browser tab? In other words, can I code an HTML5 page that plays audio and continues playing even after the iPhone is locked?
Yes, audio playing in a mobile Safari tab will continuously play even when multi-tasking or locking your screen. However, if you save the bookmark to the home screen, open, play audio, and then hop out to multi-task, the audio fades out.
Not possible... the browser displaying your page controls what happens when it is deactivated (sent to the background). HTML5 won't touch the behavior of the underlying browser as it relates to system events, so the only way to control background activity in iOS is to write a native app.

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

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 )

Resources