question

schreida avatar image
schreida asked

Capture Play Button in ActionScript

Hi, is it possible to capture the media buttons rewind, play and fast forward in an app created with Flash / ActionScript. I had no problems with left, right, up, down, enter, back and option by using KeyboardEvent.KEY_DOWN . The app plays video so it would be nice to make use of the media buttons. thx + greets
fire tv
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Schreida, Before forwarding this to concerned team I need little information from you. Could you please share your code that how you are using to detect left, right, up, down and option button pressed event. I have tried with this public function ActionScriptAndroidTest() { super(); // support autoOrients stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; myText = new TextField(); addChild(myText); setText("Republic of Code"); NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown, false, 0, true) } protected function onKeyDown(event:KeyboardEvent):void { if( event.keyCode == Keyboard.BACK ) { event.preventDefault(); event.stopImmediatePropagation(); //handle the button press here. setText( "KeyboardEvent:" + event.keyCode); } } It only can detect back on X button pressed in controller.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

schreida avatar image
schreida answered
Hi, i just used the KEY_DOWN event on my stage. Rewind, Play and Fastforward are not covered. public class Test extends Sprite { public function Test() { (stage) ? addedToStageHandler():addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler); } private function addedToStageHandler(e:Event = null):void { if (e) removeEventListener(Event.ADDED_TO_STAGE, addedToStageHandler); stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler); } public function keyDownHandler(e:KeyboardEvent):void { switch(e.keyCode) { case 16777238: trace("back"); break; case 16777234: trace("menu"); break; case 13: trace("enter"); break; case 37: trace("left"); break; case 38: trace("up"); break; case 39: trace("right"); break; case 40: trace("down"); break; } } } greets
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Thanks for the code. I have forwarded it to the concerned team. I will get back soon.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.