Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

eventlistener #1

Open
julien9999 opened this issue Mar 29, 2013 · 3 comments
Open

eventlistener #1

julien9999 opened this issue Mar 29, 2013 · 3 comments

Comments

@julien9999
Copy link

hi, i don't understand how to add an event on click play-pause media buttons.
thanks in advance

@hoyo
Copy link
Owner

hoyo commented Mar 31, 2013

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

@julien9999
Copy link
Author

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.

@hoyo
Copy link
Owner

hoyo commented Mar 31, 2013

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

hoyo pushed a commit that referenced this issue Feb 23, 2015
Added ability to set albumArtwork via URL fo locksceen info
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants