Playbook has 4 buttons (only 4). They are “Power”, “Volume Up”, “Play / Pause” and “Volume Down”. If you are working on creating some Flash application for Playbook, you might want to consider react the button press on the device. Especially for a media player app, hook up the volume buttons and play / pause button are necessary. I will give you some example about how to take care of the button press on the Playbook.
When you press the power button, the device will switch to “Sleep Mode”, press again will wake it up. You application will be set “deactivate” & “activate” for those cases. So what you need to do is listen to Event.ACTIVATE and Event.DEACTIVATE just like this:
You should also know that the events will also be fired if the app has been switch to background (swipe up from the bottom of the screen and open another app).
Volume Up / Down & Mute / UnMute
Vomue Up / Down buttons simply do what they say. Long press the Play / Pause button causes Mute and UnMute. For accessing the volume information, you need to get an instance of Playbook’s AudioManager. And listen to the AudioManagerEvent.OUTPUT_LEVEL_CHANGED and AudioManagerEvent.OUTPUT_MUTE_CHANGED events. Just like this:
// get audio manager instance
audioMgr = AudioManager.audioManager;
// hook up volume up / down
// hood up mute / unmute (by long press the play/pause button)
Play / Pause
Play / Pause button belongs to Playbook’s MediaServiceConnection. A little more codes needs to be done for hooking up the button:
mediaServiceConnection = new MediaServiceConnection;
private function onMSConnect(event:MediaServiceConnectionEvent):void
private function onMSTrackPause(event:MediaServiceRequestEvent):void
// this is the place you get the button event, each press on the Play / Pause will fire this function
// there is no need to look the event detail b/c it's useless