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.
Related
When running my app in background, I would get MediaError.MEDIA_ERR_NONE_SUPPORTED (4) when trying to create and play an audio file.
While most suggestions for this error relates to file format, file existence or audio recording, my audio files were playing perfectly when the app was in foreground.
Note: I am already using the Cordova Background Mode plugin.
It turns out that the Cordova Music Controls is causing this interference.
Without manipulating the music controls, audio plays perfectly even when the app enters background.
The problem came from destroying the music controls, which makes iOS prevent your app from playing audio until the user resumes the app to foreground.
Turns out you don't have to destroy music controls before creating them again, to update the track label.
TLDR; Don't kill music controls while playing audio in the background.
I'm trying to develop an app which shows lockscreen media controls (MPRemoteCommandCenter and MPNowPlayingInfoCenter).
The tricky part is that I'm not playing a media on the phone but on a remote server (like Google cast).
I managed to do it by playing a silent audio file on the phone which shows the lockscreen controls but it doesn't feel like a good solution (unnecessary battery drain).
Is it possible to show these controls without playing anything on the phone ?
Is it possible to keep the audio playing inside a WebView still play when an App is suspended or in background on Windows 10 or Windows Phone 8?
Correctly if in Windows 10, if an App is not focus the webview keeps playing, but in tablet mode if goes to background, the sound is muted.
Thanks in advance.
I’m afraid you cannot play the audio in WebView at background. Similar with Media Element, the audio is played by the app process, when the app is suspended (see App Life Cycle), it will stop playing the audio.
To play the audio at background in Windows Universal Apps, you need to use the BackgroundAudioPlayer, it will start a broker process and the audio will keep playing when the app process is suspended.
I've tried to write my first iOS app. It's a simple UIWebView of a site with HTML5 audio stream (radio). When app is in foreground the audio works perfectly, but, if press the home button or lock the device the audio stop!
If click play on lockscreen or on control center, audio work for about 10 second.
Any solution?
Sorry for bad english
Go to your plist and add the row "Required background modes" with the key "App plays audio or streams audio/video using AirPlay"
From http://www.raywenderlich.com/29948/backgrounding-for-ios, the part which explains Playing Audio in Background: "If it still doesn’t work for you, it is probably because you’re using the Simulator. Testing it on a device should get it working"
You should try on the Device.
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.