1

In IOS, I implemented volume control for my app on lock screen. Same thing is needed in android also. I done it in IOS by setting the plist

<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>

In controller

var player = Titanium.Media.createAudioPlayer({
   url : "/alerts/door-bell.mp3",
   allowBackground : true,
   audioSessionMode : Ti.Media.AUDIO_SESSION_MODE_PLAYBACK
});

function start(e) {
  player.play();
}

But for Android I can’t find any hint. For IOS I refereed the KitchenSink app but in android that example was excluded. Means is that not possible?. But when I played default music player, upon locking the screen, music control was showing on notification bar menu. So I am assuming this is possible for my app also. If so how can I do this in Titanium or in Android it self.

halfer
  • 19,824
  • 17
  • 99
  • 186
Kiren S
  • 3,037
  • 7
  • 41
  • 69

1 Answers1

0

For Android you need:

http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Media.AudioPlayer-property-allowBackground

Also see the example on the above page, which has:

var audioPlayer = Ti.Media.createAudioPlayer({ 
   url: 'www.example.com/podcast.mp3',
   allowBackground: true
}); 
Fokke Zandbergen
  • 3,866
  • 1
  • 11
  • 28
  • 1
    I already set allowBackground: true and audio is playing fine in background. But it was not showing on lockscreen or on notification bar menu. – Kiren S Mar 09 '15 at 05:12