Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

playerStateChanged event not triggered #14

Closed
Summys opened this issue Mar 22, 2019 · 9 comments
Closed

playerStateChanged event not triggered #14

Summys opened this issue Mar 22, 2019 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@Summys
Copy link

Summys commented Mar 22, 2019

Have you bridged the entire sdk? I can't find some useful functions like subscribing to player's state and disconnect the user.

You did an awesome job with this package, and please let me know if I can help you with something.

Edit: The listener for 'playerStateChanged' isn't triggered, remoteConnected and remoteDisconnected works properly, but I have hard times listening to player's change

@cjam
Copy link
Owner

cjam commented Dec 10, 2019

Hey sorry for the huge delay, I've been traveling around the world for the past 4 months and am getting back into this repo.

I believe I bridged most of the functionality exposed by the ios sdk, but then spotify has likely released some updates to the SDK since that need to be incorporated. My plan is to first get this repo working with CocoaPods and update to the latest SDK.

I'll be going through everything again, so I'll make sure that the playerStateChanged stuff is working. Stay tuned.

@cjam cjam self-assigned this Jan 18, 2020
@cjam cjam added the bug Something isn't working label Jan 18, 2020
@cjam cjam changed the title Basic functions needed playerStateChanged event not triggered Jan 18, 2020
cjam added a commit that referenced this issue Jan 18, 2020
cjam added a commit that referenced this issue Jan 18, 2020
* Updating SpotifySDK to v1.2.0

* Fixes and improvements:
- improving example app to be a better test-bed for features
- Fixing issues with content api
- making sure player API is working correctly
- Updating track & ContentItem to match new SDK

* #20 Exposing additional SDK methods:
- playItem
- playItemWithIndex
- getRootContentItems
- getCrossfadeState

* Removing the dist folder

* Ignoring the dist folder

* Just a bit of cleanup

* Devlopment Experience:
- update contribution guide
- add package.json scripts for running / updating

* #20 Update to the Example App
- Several different pages
- exercise various portions of library

* Updating changelog to include changes for 0.1.0
- referenced #14, #15, #20

* Small update to documentation

* Adding some typings for documentation sake
- ContentType
- RecomendedContentOptions

* Bumping version number and comitting docs
@cjam
Copy link
Owner

cjam commented Jan 18, 2020

This should be fixed in v0.1.0

@cjam cjam closed this as completed Jan 18, 2020
@garethleonard
Copy link

I am still seeing this in 0.2.2. Should the playerStateChanged event be triggered on pausing the track?

@cjam
Copy link
Owner

cjam commented Apr 10, 2020

yep it should. I'm currently using this library in an app I'm building and use the playerStateChanged event heavily

@garethleonard
Copy link

remote.addListener('playerStateChanged', event => {
  console.log(event);
});

This should do the trick, right?

@cjam
Copy link
Owner

cjam commented Apr 10, 2020

I would think so ya. This is where I'm doing it in the example app for reference:

remote.on("remoteConnected", this.onConnected)
.on("remoteDisconnected", this.onDisconnected)
.on("playerStateChanged", this.onPlayerStateChanged);

I created the example app for manually testing and also giving examples of each part of the library.
Perhaps try the on interface. Maybe there is something strange with addListener. The eventEmitter stuff is implemented by another library

@garethleonard
Copy link

Thanks. I'm sure it's my issue here. Will play around with it. Thanks for the great work!

@garethleonard
Copy link

Got it working. I was setting the wrong values on state so my UI wasn't updating. Follow-up question - should the event trigger when the playbackPosition updates? I want to keep track of a seek bar without having to keep my own timer.

@cjam
Copy link
Owner

cjam commented Apr 10, 2020

@garethleonard Unfortunately it does not. I have however wired up the playerStateChanged event so that if you request the current playerState it will fire that event when the state comes back. So a work around is you should be able to put remote.getPlayerState() on a timer but handle all the state changes in your event handler like you are now. Hope that makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants