timflapper / cordova-spotify-plugin

This plugin provides a PhoneGap / Cordova API for the Spotify iOS SDK.
MIT License
48 stars 12 forks source link

No Events Firing #3

Open paullryan opened 9 years ago

paullryan commented 9 years ago

After calling createAudioPlayer with a working player (I can play and manipulate a queue) I can't get any events to fire. I've tried registering as follows:

var audioPlayer = spotify.createAudioPlayer(clientId);
audioPlayer.addEventListener(spotify.AudioPlayer.EVENT_LOGIN, function(message){
   console.log('logged into player ' + message);
 });
audioPlayer.addEventListener(spotify.AudioPlayer.EVENT_MESSAGE, function(message){
   console.log('Got spotify message ' + message);
 });
audioPlayer.addEventListener(spotify.AudioPlayer.EVENT_PLAYBACK_STATUS, function(status){
   console.log('got playback status ' + status);
 });
audioPlayer.addEventListener(spotify.AudioPlayer.EVENT_ERROR, function(error){
   console.error(error);
 });
audioPlayer.addEventListener('volumeChanged', function(error, value){
   console.log('volumeChanged')
 });
audioPlayer.addEventListener('skippedToNextTrack', function(error, value){
   console.log('skippedToNextTrack')
 });
 audioPlayer.addEventListener('skippedToPreviousTrack', function(error, value){
   console.log('skippedToPreviousTrack')
 });

None of these ever get fired but my music is playing after calling audioPlayer play on a playlist. Any suggestions as to what I'm doing wrong.

paullryan commented 9 years ago

Oh and I'm calling login after I've added the event listeners.

paullryan commented 9 years ago

I've been digging and it appears the events are making it to eventNotificationFromAudioPlayer they just are not getting thrown back up into onEventCallback. I'm wondering if the registration for the callbackID is valid.

paullryan commented 9 years ago

I've added a branch on my repository at https://github.com/ambientBOX/cordova-spotify-plugin/tree/fix-event-callback that fixes this issue but I don't believe it's complete. Can you please review it, if it's good enough I'll submit as pull.

timflapper commented 9 years ago

I'll have a look at this issue as soon as I have some time later this week. Great work on initiating the fix.

timflapper commented 9 years ago

I believe I found a fix for this issue. I'll create a new release as soon as possible.