-
-
Notifications
You must be signed in to change notification settings - Fork 57
Extension API
A moosync extension can be split into 3 parts
- Lifecycle hooks
- Methods
- Events
There are 2 optional lifecycle hooks for an extension
- onStarted
- onStopped
onStarted hook is invoked after moosync's extension host has started or after the extension has been installed.
This method only signifies that your extension can now communicate with moosync.
It is recommended to initialize your custom code in this method.
onStopped hook is invoked after moosync's extension host has stopped or after the extension has been uninstalled.
It is recommended to destroy all objects and stop all tasks in this method.
Your extension is provided with a global constant api.
For typescript, this can be declared inside your declaration file
declare const api: import('@moosync/moosync-types').extensionAPIapi exposes some methods, namely:
- openExternalURL
- registerOAuth
- addPlaylist
- addSongsToPlaylist
- addSongs
- removeSong
- getCurrentSong
- getPlayerState
- getQueue
- getSongs
- getTime
- getVolume
- setSecure
- getSecure
- getPreferences
- setPreferences
Events can be listened to using api.on(...)
List of events:
- 'requestedPlaylists' *
- 'requestedPlaylistSongs' *
- 'oauthCallback'
- 'songQueueChanged'
- 'seeked'
- 'volumeChanged'
- 'playerStateChanged'
- 'songChanged'
- 'preferenceChanged'
- 'playbackDetailsRequested' *
- 'customRequest' *
- 'requestedSongFromURL' *
- 'requestedPlaylistFromURL' *
- 'requestSearchResult' *
- 'requestedRecommendations' *
- 'requestedLyrics' *
* These events require you to return some data from their callbacks
[ Home ] [ Building Moosync from Source ] [ Extensions ] [ Spotify and Discord Integration ]