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 | SongsWithPageTokenReturnType | 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 | SongsWithPageTokenReturnType | ForwardRequestReturnType<"requestedArtistSongs">>): void
  • on(eventName: "requestedAlbumSongs", callback: (album: Album, nextPageToken?: unknown) => Promise<void | SongsWithPageTokenReturnType | 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

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

updateSong

  • Update song in library by ID

    Parameters

    • song: Song

      song to update

    Returns Promise<Song>

Generated using TypeDoc