eventlistener
hi, i don't understand how to add an event on click play-pause media buttons. thanks in advance
Thanks for trying to use my module. How about the following code sample?
var Control = require('net.hoyohoyo.tiremotecontrol');
Control.addEventListener('remotecontrol', function(e) {
Ti.API.debug('remote control event was fired!');
switch (e.subtype) {
case Control.REMOTE_CONTROL_PLAY_PAUSE:
// code executing when clicked play-pause media button
break;
}
});
hi, thanks for your reply, actually when I try to use multiple events like the PLAY event and the PAUSE event it doesnt do anything
Control.addEventListener('remotecontrol', function(e) { Ti.API.debug('remote control event was fired!'); switch (e.subtype) { case Control.REMOTE_CONTROL_PLAY: sound.play();
break;
case Control.REMOTE_CONTROL_PAUSE:
sound.pause();
} }); Date: Sat, 30 Mar 2013 21:28:17 -0700 From: [email protected] To: [email protected] CC: [email protected] Subject: Re: [TiRemoteControl] eventlistener (#1)
Thanks for tring to use my widget.
How about the following code sample?
var Control = require('net.hoyohoyo.tiremotecontrol'); Control.addEventListener('remotecontrol', function(e) { Ti.API.debug('remote control event was fired!'); switch (e.subtype) { case Control.REMOTE_CONTROL_PLAY_PAUSE: // code executing when clicked play-pause media button break; } });
— Reply to this email directly or view it on GitHub.
I see that you want to do. You may receive REMOTE_CONTROL_PLAY_PAUSE event and use flag playing or not.
var isPlaying = false;
var Control = require('net.hoyohoyo.tiremotecontrol');
Control.addEventListener('remotecontrol', function(e) {
Ti.API.debug('remote control event was fired!');
switch (e.subtype) {
case Control.REMOTE_CONTROL_PLAY_PAUSE:
if (isPlaying) {
// code executing when clicked play-pause media button on playing
} else {
// code executing when clicked play-pause media button before playing
}
isPlaying != isPlaying;
break;
}
});