createAudioPlayer and system control
I'm creating an iPhone app and part of my app allows for the playback of remote audio files. I've created two buttons - one to play an audio file and one to pause an audio file.
var url = "http://www.mydomain.com/path/to/file.mp3";
// load from remote url
var sound = Titanium.Media.createAudioPlayer({
url:url,
audioSessionMode:Ti.Media.AUDIO_SESSION_MODE_PLAYBACK
});
var play = Titanium.UI.createButton({
... play button properties here ...
});
play.addEventListener('click', function()
{
sound.start();
});
win.add(play);
var pause = Titanium.UI.createButton({
... pause button properties here ...
});
pause.addEventListener('click', function()
{
sound.pause();
});
win.add(pause);
Also, in my info.plist to allow the audio to keep playing when a user exits the app, I have the following:
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
As far as the audio playing in the background and pausing it's working great. What I can't figure out is how to make the system iPod control (the control when you double-click the home button and swipe all the way to the left - where you see the orientation lock, rewind, play/pause, forward, and current playing app icons) pause and start the audio playing.
Any help is greatly appreciated!
4 Answers
-
I am also looking for this
-
Did either of you guys figure this out? I'm trying to get a playlist of remote audio files to play and be controlled by the lock and dock controllers. I can get the audio to play in the background and can pause it but can't figure out how to hook into the back and next buttons.
Any help is appreciated.
-
I would also really like to integrate with iPod controls (play/pause, back, next). It looks like those button events are Remote Control Events and need to be subscribed to. As per http://stackoverflow.com/questions/3361619/iphone-ios4-replacing-ipod-dock-icon-whilst-playing-background-audio-stream. I've searched the mobile API docs and I don't see any mention of Remote Control events or iPod control events. Titanium please provide an API for these!
-
I've put a module in the marketplace for that.
https://marketplace.appcelerator.com/apps/1109