How to play a mp3 stream integrated into iPod on iOS - ios

I have a standard mp3 stream that is delivered through http. I use the approach used in this example project:
https://github.com/mattgallagher/AudioStreamer/
Basically it uses the approach described in Apples "Audio Stream Reference". If I set UIBackgroundModes to audio iOS plays the sound if the app is in the background.
But how can I make the iPod controls in the taskbar work? How can I integrate properly with iPod on iOS?

The controls in the taskbar fire remote-control events (for example like controls that are integrated into the head phones). If you follow the instructions described in Apples documentation Remote Control of Multimedia and set UIBackgroundModes to audio, then everything behaves as expected: If the app is suspended the sound continues to play, you app icon appears in the iPod menu in the taskbar and the buttons trigger events.

Related

How can I play music successively in the background with UIWebView or WKWebView

The website implemented inside my app would play a series of mp3 files,it works well when the app is active,but when I press HOME button or lock the phone,it cannont play more than ONE song in the background,after that,app suspended.
I've already tried to set different kind of AVAudioSession Category,but of no use.
I assume you don't have audio background mode enabled. This is what Apple documentation says:
When the UIBackgroundModes key contains the audio value, the system’s media frameworks automatically prevent the corresponding app from being suspended when it moves to the background. As long as it is playing audio or video content or recording audio content, the app continues to run in the background. However, if recording or playback stops, the system suspends the app.
So it seems like you just need to enable audio background mode. Here is Ray Wenderlich's tutorial on background modes

iOS webview and audio html5 on background

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.

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.

iOS: App Home Button Shortcut

Having trouble finding the API for the home screen shortcuts when the home button is clicked. My app plays audio and I want those similar shortcuts to pop up like the do for the iPod to give me the option to stop playback.
Can someone just point me to the reference?
This is a good place to start:
Remote Control Events
From the Apple documentation:
Test that your app is properly receiving and handling remote control
events with the Now Playing Controls. These controls are available on
recent iOS devices that are running iOS 4.0 or later. To access these
controls, press the Home button twice, then flick right along the
bottom of the screen until you find the audio playback controls. These
controls send remote control events to the app that is currently or
was most recently playing audio. The icon to the right of the playback
controls represents the app that is currently receiving the remote
control events.

How to integrate a music player in iOS system

How can I integrate a music app in the iOS system that my own custom player can handle actions (play, pause, forward) from the unlock screen and how to integrate that is displayed as player app in the double-click-home-button menu like on this screenshot Spotify does:
EDIT: The application itself is based at the Media Player Framework, but in this documents there isn't any hint how to get the custom player in this 'double-click-home-button' menu.
If you register your application for remote control events, and if you start playing either audio or video, your application will automatically take over these controls. See Apple's documentation for more info. This API is available on iOS 4 and later.
To set the string below the controls ("The Butterfly Defect" in your screenshot), use MPNowPlayingInfoCenter, available on iOS 5 and later.

Resources