Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • extensionAPI

Index

Properties

player

Object containing controls for player

utils

utils: utils

Methods

addPlaylist

  • addPlaylist(playlist: Omit<Playlist, "playlist_id">): Promise<string>
  • Add playlist to library

    Parameters

    • playlist: Omit<Playlist, "playlist_id">

      details of playlist which is to be added to library

    Returns Promise<string>

    ID of playlist which has been added

addSongs

  • addSongs(...songs: Song[]): Promise<Song[]>
  • Add songs to library

    Parameters

    • Rest ...songs: Song[]

      1 or more songs that are to be added to library

    Returns Promise<Song[]>

    array of booleans with same index as song. True means song has been added successfully

addSongsToPlaylist

  • addSongsToPlaylist(playlistID: string, ...songs: Song[]): Promise<void>
  • Add songs to playlist in library. The song must also exist in the library

    Parameters

    • playlistID: string

      ID of playlist in which songs are to be added

    • Rest ...songs: Song[]

      Songs which are to be added in the playlist

    Returns Promise<void>

addUserPreference

changeAccountAuthStatus

  • changeAccountAuthStatus(id: string, loggedIn: boolean, username?: string): Promise<void>
  • Change login status and signed in user's account name.

    Parameters

    • id: string

      accountId to change details of. Returned from registerAccount

    • loggedIn: boolean

      true if user is logged in otherwise false

    • Optional username: string

    Returns Promise<void>

closeLoginModal

  • closeLoginModal(): Promise<void>
  • Close login modal if its open

    Returns Promise<void>

getContextMenuItems

getCurrentSong

  • getCurrentSong(): Promise<Song>
  • Get the current playing track. Undefined if no track is playing

    Returns Promise<Song>

getEntity

getInstalledExtensions

  • getInstalledExtensions(): string[]
  • Returns a list of package names of all installed extensions

    Returns string[]

getPlayerState

  • Get state of music player. Undefined is player is broken and audio can't be loaded

    Returns Promise<PlayerState>

getPreferences

  • getPreferences<T>(key?: string, defaultValue?: unknown): Promise<T>
  • Fetch preferences by key. If no key is provided, all preferences co-relating to current extension will be fetched.

    Type parameters

    • T

    Parameters

    • Optional key: string

      key of preference to fetch. keys within complex objects can be separated by .

    • Optional defaultValue: unknown

      If the provided key is not found, then default value will be returned.

    Returns Promise<T>

getQueue

getSecure

  • getSecure<T>(key: string, defaultValue?: unknown): Promise<T>
  • Get decrypted value of an encrypted preference

    Type parameters

    • T

    Parameters

    • key: string

      key of preference to fetch. keys within complex objects can be separated by .

    • Optional defaultValue: unknown

      If the provided key is not found, then default value will be returned.

    Returns Promise<T>

getSongs

getTime

  • getTime(): Promise<number>
  • Get current time of the player.

    Returns Promise<number>

getVolume

  • getVolume(): Promise<number>
  • Get volume directly from the audio player

    Returns Promise<number>

off

  • off<T>(eventName: T): void

on

  • on(eventName: "requestedPlaylists", callback: (invalidateCache: boolean) => Promise<void | PlaylistReturnType>): void
  • on(eventName: "requestedPlaylistSongs", callback: (playlistID: string, invalidateCache: boolean, nextPageToken?: unknown) => Promise<void | SongsReturnType | ForwardRequestReturnType<"requestedPlaylistSongs">>): void
  • on(eventName: "oauthCallback", callback: (url: string) => Promise<void>): void
  • on(eventName: "songQueueChanged", callback: (songQueue: SongQueue) => Promise<void>): void
  • on(eventName: "seeked", callback: (newTime: number) => Promise<void>): void
  • on(eventName: "volumeChanged", callback: (newVolume: number) => Promise<void>): void
  • on(eventName: "playerStateChanged", callback: (newState: PlayerState) => Promise<void>): void
  • on(eventName: "songChanged", callback: (song: Song) => Promise<void>): void
  • on(eventName: "preferenceChanged", callback: (preference: { key: string; value: unknown }) => Promise<void>): void
  • on(eventName: "playbackDetailsRequested", callback: (song: Song) => Promise<void | PlaybackDetailsReturnType | ForwardRequestReturnType<"playbackDetailsRequested">>): void
  • on(eventName: "customRequest", callback: (url: string) => Promise<void | CustomRequestReturnType>): void
  • on(eventName: "requestedSongFromURL", callback: (url: string) => Promise<void | SongReturnType | ForwardRequestReturnType<"requestedSongFromURL">>): void
  • on(eventName: "requestedPlaylistFromURL", callback: (url: string) => Promise<void | PlaylistAndSongsReturnType | ForwardRequestReturnType<"requestedPlaylistFromURL">>): void
  • on(eventName: "requestedSearchResult", callback: (term: string) => Promise<void | SearchReturnType | ForwardRequestReturnType<"requestedSearchResult">>): void
  • on(eventName: "requestedRecommendations", callback: () => Promise<void | RecommendationsReturnType | ForwardRequestReturnType<"requestedRecommendations">>): void
  • on(eventName: "requestedLyrics", callback: (song: Song) => Promise<string | void | ForwardRequestReturnType<"requestedLyrics">>): void
  • on(eventName: "requestedArtistSongs", callback: (artist: Artists, nextPageToken?: unknown) => Promise<void | SongsReturnType | ForwardRequestReturnType<"requestedArtistSongs">>): void
  • on(eventName: "requestedAlbumSongs", callback: (album: Album, nextPageToken?: unknown) => Promise<void | SongsReturnType | ForwardRequestReturnType<"requestedAlbumSongs">>): void
  • on(eventName: "requestedSongFromId", callback: (url: string) => Promise<void | SongReturnType | ForwardRequestReturnType<"requestedSongFromId">>): void
  • on(eventName: "songAdded", callback: (songs: Song[]) => Promise<void>): void
  • on(eventName: "songRemoved", callback: (songs: Song[]) => Promise<void>): void
  • on(eventName: "playlistAdded", callback: (playlist: Playlist[]) => Promise<void>): void
  • on(eventName: "playlistRemoved", callback: (songs: Playlist[]) => Promise<void>): void
  • Event fired when playlists are requested by the user The callback should return and result playlists or undefined

    Parameters

    Returns void

  • Event fired when songs of a single playlist are requested by the user The callback should return result songs or undefined

    Parameters

    Returns void

  • Event fired when moosync is passed url containing registered oauth channel name Oauth channel should be registered using registerOAuth

    Parameters

    • eventName: "oauthCallback"
    • callback: (url: string) => Promise<void>
        • (url: string): Promise<void>
        • Parameters

          • url: string

          Returns Promise<void>

    Returns void

  • Event fired when song queue changes order or new song is added or removed

    Parameters

    • eventName: "songQueueChanged"
    • callback: (songQueue: SongQueue) => Promise<void>

    Returns void

  • Event fired when user seeks player manually

    Parameters

    • eventName: "seeked"
    • callback: (newTime: number) => Promise<void>
        • (newTime: number): Promise<void>
        • Parameters

          • newTime: number

          Returns Promise<void>

    Returns void

  • Event fired when user changes volume

    Parameters

    • eventName: "volumeChanged"
    • callback: (newVolume: number) => Promise<void>
        • (newVolume: number): Promise<void>
        • Parameters

          • newVolume: number

          Returns Promise<void>

    Returns void

  • Event fired when player changes state to / from paused, stopped, playing, loading

    Parameters

    • eventName: "playerStateChanged"
    • callback: (newState: PlayerState) => Promise<void>

    Returns void

  • Event fired when new song is loaded into player

    Parameters

    • eventName: "songChanged"
    • callback: (song: Song) => Promise<void>
        • (song: Song): Promise<void>
        • Parameters

          Returns Promise<void>

    Returns void

  • Event fired when preferences corresponding to the extension are changed

    Parameters

    • eventName: "preferenceChanged"
    • callback: (preference: { key: string; value: unknown }) => Promise<void>
        • (preference: { key: string; value: unknown }): Promise<void>
        • Parameters

          • preference: { key: string; value: unknown }
            • key: string
            • value: unknown

          Returns Promise<void>

    Returns void

  • Event fired when song provided by the extension lacks Song.playbackUrl or Song.duration Callback should return both playbackUrl and duration even if only either is missing or undefined.

    Can be used to dynamically provide playbackUrl and/or duration

    Parameters

    Returns void

  • Event fired when custom url corresponding to the extension is called Callback should return data as buffer and mimetype for the same or undefined

    if an url extension://moosync.extension.packageName/testData is provided to Moosync. When the url is fetched, this event will be triggered and custom data can be provided at runtime

    example

    const song: Song = { ..., song_coverPath_high: 'extension://moosync.extension.packageName/coverPathUrl', ... playbackUrl: 'extension://moosync.extension.packageName/testData' }

    Parameters

    Returns void

  • Event fired when user enters url in 'Add song from URL' modal Callback should return parsed song or undefined

    Parameters

    Returns void

  • Event fired when user enters url in 'Add playlist from URL' modal Callback should return a playlist and parsed songs in that playlist or undefined

    Parameters

    Returns void

  • Event fired when user searches a term in search page Callback should return a providerName and result songs or undefined

    Parameters

    Returns void

  • Event fired when user opens Explore page Callback should return a providerName and result songs or undefined

    Parameters

    Returns void

  • Event fired when lyrics are requested for a song Callback should return a string (HTML formatting) with lyrics or undefined

    Parameters

    Returns void

  • Event fired when songs by a particular artist are requested Callback should return parsed songs or undefined

    Parameters

    Returns void

  • Event fired when songs by a particular album are requested Callback should return parsed songs or undefined

    Parameters

    Returns void

  • Event fired when the app only has id for the song but requires complete details Callback should return parsed song or undefined

    Parameters

    Returns void

  • Event fired when songs are added to library

    Parameters

    • eventName: "songAdded"
    • callback: (songs: Song[]) => Promise<void>
        • (songs: Song[]): Promise<void>
        • Parameters

          Returns Promise<void>

    Returns void

  • Event fired when songs are removed from library

    Parameters

    • eventName: "songRemoved"
    • callback: (songs: Song[]) => Promise<void>
        • (songs: Song[]): Promise<void>
        • Parameters

          Returns Promise<void>

    Returns void

  • Event fired when playlist is added to library

    Parameters

    • eventName: "playlistAdded"
    • callback: (playlist: Playlist[]) => Promise<void>
        • Parameters

          Returns Promise<void>

    Returns void

  • Event fired when playlist is removed from library

    Parameters

    • eventName: "playlistRemoved"
    • callback: (songs: Playlist[]) => Promise<void>
        • Parameters

          Returns Promise<void>

    Returns void

openExternalURL

  • openExternalURL(url: string): Promise<void>
  • Open a url in system browser

    Parameters

    • url: string

      string corresponding to URL which is to be opened

    Returns Promise<void>

openLoginModal

  • Open login modal. Show the modal if the extension demands the user to open a linux to fulfill OAuth requirements.

    The modal also allows the user to manually enter a token or manually click a button when the task is fulfilled

    Parameters

    Returns Promise<boolean>

registerAccount

  • registerAccount(name: string, bgColor: string, icon: string, signinCallback: () => void | Promise<void>, signoutCallback: () => void | Promise<void>): Promise<string>
  • Add an account to show in accounts section in main app. The user will then be able to perform login / logout operations on this account and also view its details

    Parameters

    • name: string

      name of service provider

    • bgColor: string

      background color to use for account card (in hex format. Eg. #000000)

    • icon: string

      icon of account (preferably service provider's icon)

    • signinCallback: () => void | Promise<void>

      callback fired when user wishes to login

        • (): void | Promise<void>
        • Returns void | Promise<void>

    • signoutCallback: () => void | Promise<void>

      callback fired when user wishes to logout

        • (): void | Promise<void>
        • Returns void | Promise<void>

    Returns Promise<string>

    generated accountId

registerOAuth

  • registerOAuth(path: string): Promise<void>
  • Register a callback for Oauth on given path. This OAuth can be triggered by calling the url moosync://{path} If the path matches, the whole URL is passed to this extension.

    Parameters

    • path: string

      path on which the callback will be triggered

    Returns Promise<void>

removeContextMenuItem

  • removeContextMenuItem(index: number): void
  • Remove an item from context menu

    Parameters

    • index: number

      index of context menu item which is to be removed

    Returns void

removeSong

  • removeSong(song_id: string): Promise<void>
  • removeSong(song: Song): Promise<void>
  • deprecated

    pass song instead of song_id Remove song from library

    Parameters

    • song_id: string

      id of song to remove

    Returns Promise<void>

  • Remove song from library

    Parameters

    • song: Song

      song to remove

    Returns Promise<void>

removeUserPreference

  • removeUserPreference(key: string): void

setAlbumEditableInfo

  • setAlbumEditableInfo(artist_id: string, object: Record<string, string>): Promise<void>
  • Set extra info for an album. This info is editable by the user using "Show info" context menu option on album

    Parameters

    • artist_id: string
    • object: Record<string, string>

      Key-value pairs of editable info

    Returns Promise<void>

setArtistEditableInfo

  • setArtistEditableInfo(artist_id: string, object: Record<string, string>): Promise<void>
  • Set extra info for an artist. This info is editable by the user using "Show info" context menu option on artist

    Parameters

    • artist_id: string
    • object: Record<string, string>

      Key-value pairs of editable info

    Returns Promise<void>

setContextMenuItem

setPreferences

  • setPreferences(key: string, value: unknown): Promise<void>
  • Set preference by key.

    Parameters

    • key: string

      key separated by '.'

    • value: unknown

      value to be stored for corresponding key

    Returns Promise<void>

setSecure

  • setSecure(key: string, value: unknown): Promise<void>
  • Encrypt value and store in preferences

    Parameters

    • key: string

      key separated by '.'

    • value: unknown

      value to be stored for corresponding key

    Returns Promise<void>

showToast

  • showToast(message: string, duration?: number, type?: "success" | "info" | "error" | "default"): any
  • Show toast on top-right of screen

    Parameters

    • message: string

      message to show in toast

    • Optional duration: number

      duration of toast in milliseconds. Maximum 5000ms

    • Optional type: "success" | "info" | "error" | "default"

      type of toast. Usually denotes color

    Returns any

Generated using TypeDoc