import { Event, RepeatMode, AndroidAutoContentStyle } from './constants'; import type { AddTrack, EventPayloadByEvent, NowPlayingMetadata, PlaybackState, PlayerOptions, Progress, ServiceHandler, Track, TrackMetadataBase, UpdateOptions, AndroidAutoBrowseTree } from './interfaces'; /** * Initializes the player with the specified options. * * Note that on Android this method must only be called while the app is in the * foreground, otherwise it will throw an error with code * `'android_cannot_setup_player_in_background'`. In this case you can wait for * the app to be in the foreground and try again. * * @param options The options to initialize the player with. * @see https://rntp.dev/docs/api/functions/lifecycle */ export declare function setupPlayer(options?: PlayerOptions, background?: boolean): Promise; /** * Register the playback service. The service will run as long as the player runs. */ export declare function registerPlaybackService(factory: () => ServiceHandler): void; export declare function addEventListener(event: T, listener: EventPayloadByEvent[T] extends never ? () => void : (event: EventPayloadByEvent[T]) => void): import("react-native").EmitterSubscription; /** * Adds one or more tracks to the queue. * * @param tracks The tracks to add to the queue. * @param insertBeforeIndex (Optional) The index to insert the tracks before. * By default the tracks will be added to the end of the queue. */ export declare function add(tracks: AddTrack[], insertBeforeIndex?: number): Promise; /** * Adds a track to the queue. * * @param track The track to add to the queue. * @param insertBeforeIndex (Optional) The index to insert the track before. * By default the track will be added to the end of the queue. */ export declare function add(track: AddTrack, insertBeforeIndex?: number): Promise; /** * Replaces the current track or loads the track as the first in the queue. * * @param track The track to load. */ export declare function load(track: Track): Promise; /** * Move a track within the queue. * * @param fromIndex The index of the track to be moved. * @param toIndex The index to move the track to. If the index is larger than * the size of the queue, then the track is moved to the end of the queue. */ export declare function move(fromIndex: number, toIndex: number): Promise; /** * Removes multiple tracks from the queue by their indexes. * * If the current track is removed, the next track will activated. If the * current track was the last track in the queue, the first track will be * activated. * * @param indexes The indexes of the tracks to be removed. */ export declare function remove(indexes: number[]): Promise; /** * Removes a track from the queue by its index. * * If the current track is removed, the next track will activated. If the * current track was the last track in the queue, the first track will be * activated. * * @param index The index of the track to be removed. */ export declare function remove(index: number): Promise; /** * Clears any upcoming tracks from the queue. */ export declare function removeUpcomingTracks(): Promise; /** * Skips to a track in the queue. * * @param index The index of the track to skip to. * @param initialPosition (Optional) The initial position to seek to in seconds. */ export declare function skip(index: number, initialPosition?: number): Promise; /** * Skips to the next track in the queue. * * @param initialPosition (Optional) The initial position to seek to in seconds. */ export declare function skipToNext(initialPosition?: number): Promise; /** * Skips to the previous track in the queue. * * @param initialPosition (Optional) The initial position to seek to in seconds. */ export declare function skipToPrevious(initialPosition?: number): Promise; /** * Updates the configuration for the components. * * @param options The options to update. * @see https://rntp.dev/docs/api/functions/player#updateoptionsoptions */ export declare function updateOptions({ alwaysPauseOnInterruption, ...options }?: UpdateOptions): Promise; /** * Updates the metadata of a track in the queue. If the current track is updated, * the notification and the Now Playing Center will be updated accordingly. * * @param trackIndex The index of the track whose metadata will be updated. * @param metadata The metadata to update. */ export declare function updateMetadataForTrack(trackIndex: number, metadata: TrackMetadataBase): Promise; /** * Updates the metadata content of the notification (Android) and the Now Playing Center (iOS) * without affecting the data stored for the current track. */ export declare function updateNowPlayingMetadata(metadata: NowPlayingMetadata): Promise; /** * Resets the player stopping the current track and clearing the queue. */ export declare function reset(): Promise; /** * Plays or resumes the current track. */ export declare function play(): Promise; /** * Pauses the current track. */ export declare function pause(): Promise; /** * Stops the current track. */ export declare function stop(): Promise; /** * Sets whether the player will play automatically when it is ready to do so. * This is the equivalent of calling `TrackPlayer.play()` when `playWhenReady = true` * or `TrackPlayer.pause()` when `playWhenReady = false`. */ export declare function setPlayWhenReady(playWhenReady: boolean): Promise; /** * Gets whether the player will play automatically when it is ready to do so. */ export declare function getPlayWhenReady(): Promise; /** * Seeks to a specified time position in the current track. * * @param position The position to seek to in seconds. */ export declare function seekTo(position: number): Promise; /** * Seeks by a relative time offset in the current track. * * @param offset The time offset to seek by in seconds. */ export declare function seekBy(offset: number): Promise; /** * Sets the volume of the player. * * @param volume The volume as a number between 0 and 1. */ export declare function setVolume(level: number): Promise; /** * Sets the volume of the player with a simple linear scaling. * In Android this is achieved via a native thread call. * In other platforms this is achieved via RN's Animated.Value. * * @param volume The volume as a number between 0 and 1. * @param duration The duration of the animation in milliseconds. defualt is 0 ms, which just functions as TP.setVolume. * @param init The initial value of the volume. This may be useful eg to be 0 for a fade in event. * @param interval The interval of the animation in milliseconds. default is 20 ms. * @param msg (Android) The message to be emitted after volume is fully changed, via Event.PlaybackAnimatedVolumeChanged. * @param callback (other platforms) The callback to be called after volume is fully changed. */ export declare const setAnimatedVolume: ({ volume, duration, init, interval, msg, callback, }: { volume: number; duration?: number; init?: number; interval?: number; msg?: string; callback?: () => void | Promise; }) => Promise; /** * performs fading out to pause playback. * @param duration duration of the fade progress in ms * @param interval interval of the fade progress in ms */ export declare const fadeOutPause: (duration?: number, interval?: number) => Promise; /** * performs fading into playing the next track. * @param duration duration of the fade progress in ms * @param interval interval of the fade progress in ms * @param toVolume volume to fade into */ export declare const fadeOutNext: (duration?: number, interval?: number, toVolume?: number) => Promise; /** * performs fading into playing the previous track. * @param duration duration of the fade progress in ms * @param interval interval of the fade progress in ms * @param toVolume volume to fade into */ export declare const fadeOutPrevious: (duration?: number, interval?: number, toVolume?: number) => Promise; /** * performs fading into skipping to a track. * @param index the index of the track to skip to * @param duration duration of the fade progress in ms * @param interval interval of the fade progress in ms * @param toVolume volume to fade into */ export declare const fadeOutJump: (index: number, duration?: number, interval?: number, toVolume?: number) => Promise; /** * Sets the playback rate. * * @param rate The playback rate to change to, where 0.5 would be half speed, * 1 would be regular speed, 2 would be double speed etc. */ export declare function setRate(rate: number): Promise; /** * Sets the playback pitch. android only * * @param pitch The pitch. */ export declare function setPitch(pitch: number): Promise; /** * Sets the queue. * * @param tracks The tracks to set as the queue. * @see https://rntp.dev/docs/api/constants/repeat-mode */ export declare function setQueue(tracks: Track[]): Promise; /** * Sets the queue repeat mode. * * @param repeatMode The repeat mode to set. * @see https://rntp.dev/docs/api/constants/repeat-mode */ export declare function setRepeatMode(mode: RepeatMode): Promise; /** * Gets the volume of the player as a number between 0 and 1. */ export declare function getVolume(): Promise; /** * Gets the playback rate where 0.5 would be half speed, 1 would be * regular speed and 2 would be double speed etc. */ export declare function getRate(): Promise; /** * Gets the pitch of the track. */ export declare function getPitch(): Promise; /** * Gets a track object from the queue. * * @param index The index of the track. * @returns The track object or undefined if there isn't a track object at that * index. */ export declare function getTrack(index: number): Promise; /** * Gets the whole queue. */ export declare function getQueue(): Promise; /** * Gets the index of the active track in the queue or undefined if there is no * current track. */ export declare function getActiveTrackIndex(): Promise; /** * Gets the active track or undefined if there is no current track. */ export declare function getActiveTrack(): Promise; /** * Gets information on the progress of the currently active track, including its * current playback position in seconds, buffered position in seconds and * duration in seconds. */ export declare function getProgress(): Promise; /** * Gets the playback state of the player. * * @see https://rntp.dev/docs/api/constants/state */ export declare function getPlaybackState(): Promise; /** * Gets the queue repeat mode. * * @see https://rntp.dev/docs/api/constants/repeat-mode */ export declare function getRepeatMode(): Promise; /** * Retries the current item when the playback state is `State.Error`. */ export declare function retry(): Promise; /** * Sets the content hierarchy of Android Auto (Android only). The hierarchy structure is a dict with * the mediaId as keys, and a list of MediaItem as values. To use, you must at least specify the root directory, where * the key is "/". If the root directory contains BROWSABLE MediaItems, they will be shown as tabs. Do note Google requires * AA to have a max of 4 tabs. You may then set the mediaId keys of the browsable MediaItems to be a list of other MediaItems. * * @param browseTree the content hierarchy dict. * @returns a serialized copy of the browseTree set by native. For debug purposes. */ export declare function setBrowseTree(browseTree: AndroidAutoBrowseTree): Promise; /** * this method enables android auto playback progress tracking; see * https://developer.android.com/training/cars/media#browse-progress-bar * android only. * @param mediaID the mediaID. * @returns */ export declare function setPlaybackState(mediaID: string): Promise; /** * Sets the content style of Android Auto (Android only). * there are list style and grid style. see https://developer.android.com/training/cars/media#apply_content_style . * the styles are applicable to browsable nodes and playable nodes. setting the args to true will yield the list style. * false = the grid style. */ export declare function setBrowseTreeStyle(browsableStyle: AndroidAutoContentStyle, playableStyle: AndroidAutoContentStyle): null; /** * acquires the wake lock of MusicService (android only.) */ export declare function acquireWakeLock(): Promise; /** * acquires the wake lock of MusicService (android only.) */ export declare function abandonWakeLock(): Promise; /** * prepare to crossfade (android only.) the crossfade alternate * player will be automatically primed to the current player's index, * then by previous = true or not, skip to previous or next. player * will be prepared. its advised to call this well before actually performing * crossfade so the resource can be prepared. */ export declare function crossFadePrepare(previous?: boolean, seekTo?: number): Promise; /** * perform crossfade (android only). * * fadeDuration and fadeInterval are both in ms. * * fadeToVolume is a float from 0-1. * * waitUntil is in ms. */ export declare function crossFade(fadeDuration?: number, fadeInterval?: number, fadeToVolume?: number, waitUntil?: number): Promise; /** * get the last connected package. non android will return undefined. * * android without a connected package (either system.UI, android auto, or media controller) yet * will return ''; else will be one of the three. * * I intend to use this to determine if app crashed from android auto. */ export declare function getLastConnectedPackage(): Promise;