Kiren S
Kiren S

Reputation: 3097

Volume control on lock screen or notification bar in titanium android

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.

Upvotes: 1

Views: 607

Answers (1)

Fokke Zandbergen
Fokke Zandbergen

Reputation: 3866

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
}); 

Upvotes: 0

Related Questions