Created
October 2, 2012 21:04
-
-
Save jgranick/3823303 to your computer and use it in GitHub Desktop.
How to use the "remote-control" library (NME recipe)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nme.display.Sprite; | |
import nme.events.RemoteControlEvent; | |
import nme.ui.RemoteControl; | |
class RemoteControlExample extends Sprite { | |
public function new () { | |
super (); | |
RemoteControl.addEventListener (RemoteControlEvent.BUTTON_DOWN, RemoteControl_onButtonDown); | |
RemoteControl.addEventListener (RemoteControlEvent.BUTTON_DOWN, RemoteControl_onButtonUp); | |
} | |
private function RemoteControl_onButtonDown (event:RemoteControlEvent):Void { | |
switch (event.code) { | |
case RemoteControl.NEXT: trace ("Pressed next button"); | |
case RemoteControl.PREVIOUS: trace ("Pressed previous button"); | |
case RemoteControl.HOME: trace ("Pressed home button"); | |
case RemoteControl.PLAY_PAUSE: trace ("Pressed play/pause button"); | |
case RemoteControl.VOLUME_UP: trace ("Pressed volume up button"); | |
case RemoteControl.VOLUME_DOWN: trace ("Pressed volume down button"); | |
case RemoteControl.NEXT_HOLD: trace ("Pressed and held next button"); | |
case RemoteControl.PREVIOUS_HOLD: trace ("Pressed and held previous button"); | |
case RemoteControl.MENU_HOLD: trace ("Pressed and held menu button"); | |
case RemoteControl.PLAY_PAUSE_HOLD: trace ("Pressed and held play/pause button"); | |
} | |
} | |
private function RemoteControl_onButtonUp (event:RemoteControlEvent):Void { | |
switch (event.code) { | |
case RemoteControl.NEXT: trace ("Released next button"); | |
case RemoteControl.PREVIOUS: trace ("Released previous button"); | |
case RemoteControl.HOME: trace ("Released home button"); | |
case RemoteControl.PLAY_PAUSE: trace ("Released play/pause button"); | |
case RemoteControl.VOLUME_UP: trace ("Released volume up button"); | |
case RemoteControl.VOLUME_DOWN: trace ("Released volume down button"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment