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

Globalized the song info and song controls, and updated Touch Bar for it. #102

Merged
merged 7 commits into from
Jan 10, 2021
Merged

Globalized the song info and song controls, and updated Touch Bar for it. #102

merged 7 commits into from
Jan 10, 2021

Conversation

semvis123
Copy link
Contributor

@semvis123 semvis123 commented Dec 21, 2020

Globalized the song info and song controls.
Now plugins can retrieve the song info.
The plugins don't need to import anything extra to use the song information or controls.
The plugins are able to register a callback for song info changes using

global.songInfo.onNewData( (songInfo) => {} )

songInfo is an object, containing the following properties.

title: String
artist: String
views:  String
likes: String
imageSrc: String
image: NativeImage
isPaused: Boolean
onNewData: Void

and the song can be controlled using one of the following functions:

global.songControls.previous()
global.songControls.pause()
global.songControls.next()
global.songControls.like()
global.songControls.dislike()

The songInfo plugin should eventually get another location, because it isn't really a plugin.

I've already changed the Touch Bar plugin so that it implements this.

Sem Vissscher and others added 4 commits December 21, 2020 18:18
… button.

Globalized the songinfo and song controls, and changed the pause/play button. The songInfo file should eventually get another location, because it isn't really a plugin.
Copy link
Owner

@th-ch th-ch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing job, thanks for the contribution! 👏

As you mentioned in the PR description, song-info is not really a plugin but more a provider for other plugins, so it should be put in a separate providers folders with each plugin using it instantiating the songInfo global (here, if a plugin like notifications is enabled but not song-info, we get Uncaught Exception: TypeError: Cannot read property 'onNewData' of undefined)

If you want to make the follow up to have a separate providers folder, feel free! Otherwise, I'm fine with merging and doing the follow up, PR is ✅

plugins/songInfo/back.js Outdated Show resolved Hide resolved
plugins/songInfo/back.js Outdated Show resolved Hide resolved
@semvis123
Copy link
Contributor Author

No problem, I'm glad you liked this 👍
I have changed the little things, this should be enough for a working version, but preferably the providers should not be hard coded.

Copy link
Owner

@th-ch th-ch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be enough for a working version

Agreed, I can do the refactoring for provider instantiation in another PR, merging this one! ✅ 🎉

@th-ch th-ch merged commit 77e24f4 into th-ch:master Jan 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants