import Vnmf from '../../index' declare module '../../index' { namespace stopBackgroundAudio { interface Option { /** Interface call to the end of echo function(Call successfully、Any failure will be enforced.) */ complete?: (res: VnmfGeneral.CallbackResult) => void /** Interface call failed echo function */ fail?: (res: VnmfGeneral.CallbackResult) => void /** Interface calls a successful echo function */ success?: (res: VnmfGeneral.CallbackResult) => void } } namespace seekBackgroundAudio { interface Option { /** Music Position,Units:sec */ position: number /** Interface call to the end of echo function(Call successfully、Any failure will be enforced.) */ complete?: (res: VnmfGeneral.CallbackResult) => void /** Interface call failed echo function */ fail?: (res: VnmfGeneral.CallbackResult) => void /** Interface calls a successful echo function */ success?: (res: VnmfGeneral.CallbackResult) => void } } namespace playBackgroundAudio { interface Option { /** Music Links,The format currently supported is as follows: m4a, aac, mp3, wav */ dataUrl: string /** Interface call to the end of echo function(Call successfully、Any failure will be enforced.) */ complete?: (res: VnmfGeneral.CallbackResult) => void /** CoverURL */ coverImgUrl?: string /** Interface call failed echo function */ fail?: (res: VnmfGeneral.CallbackResult) => void /** Interface calls a successful echo function */ success?: (res: VnmfGeneral.CallbackResult) => void /** Music Title */ title?: string } } namespace pauseBackgroundAudio { interface Option { /** Interface call to the end of echo function(Call successfully、Any failure will be enforced.) */ complete?: (res: VnmfGeneral.CallbackResult) => void /** Interface call failed echo function */ fail?: (res: VnmfGeneral.CallbackResult) => void /** Interface calls a successful echo function */ success?: (res: VnmfGeneral.CallbackResult) => void } } namespace getBackgroundAudioPlayerState { interface Option { /** Interface call to the end of echo function(Call successfully、Any failure will be enforced.) */ complete?: (res: VnmfGeneral.CallbackResult) => void /** Interface call failed echo function */ fail?: (res: VnmfGeneral.CallbackResult) => void /** Interface calls a successful echo function */ success?: (result: SuccessCallbackResult) => void } interface SuccessCallbackResult extends VnmfGeneral.CallbackResult { /** Could not close temporary folder: %s(Units:s),Returns only when playing music */ currentPosition: number /** Song Data Link,Returns only when playing music */ dataUrl: string /** Percentage of audio download progress,Returns only when playing music */ downloadPercent: number /** Length of selected audio(Units:s),Returns only when playing music */ duration: number /** Play State */ status: keyof Status /** Call Results */ errMsg: string } interface Status { /** Pauseing */ 0 /** Playing */ 1 /** No music playing */ 2 } } /** BackgroundAudioManager Example,Through [Vnmf.getBackgroundAudioManager](/docs/apis/media/background-audio/getBackgroundAudioManager) Fetch。 * @example * ```tsx * const backgroundAudioManager = Vnmf.getBackgroundAudioManager() * backgroundAudioManager.title = '♪ Right now, right now' * backgroundAudioManager.epname = '♪ Right now, right now' * backgroundAudioManager.singer = 'Xu Jian.' * backgroundAudioManager.coverImgUrl = 'https://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000' * // Set src It'll be played automatically after that. * backgroundAudioManager.src = 'https://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E061FF02C31F716658E5C81F5594D561F2E88B854E81CAAB7806D5E4F103E55D33C16F3FAC506D1AB172DE8600B37E43FAD&fromtag=46' * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/BackgroundAudioManager.html */ interface BackgroundAudioManager { /** Audio Data Sources([2.2.3](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) Start supporting cloud filesID)。Default to Empty Strings,**When a new setup is in place src Hour,It starts playing automatically.**,The format currently supported is as follows: m4a, aac, mp3, wav。 */ src: string /** Location where audio starts playing(Units:s)。 */ startTime: number /** Audio Title,Audio captions for native audio players(Must be filled in)。Sharing functionality in native audio players,Share the title of card,This value will also be used。 */ title: string /** Album Name,Sharing functionality in native audio players,Share an overview of the cards,This value will also be used。 */ epname: string /** Singer's name.,Sharing functionality in native audio players,Share an overview of the cards,This value will also be used。 */ singer: string /** Cover Chart URL,A background map for the raw audio player。Sharing functionality in native audio players,The shared card map and background will also be used。 */ coverImgUrl: string /** Page Link,Sharing functionality in native audio players,Share an overview of the cards,This value will also be used。 */ webUrl: string /** Audio protocol。Default value is 'http',Settings 'hls' Supportable for playback HLS Protocol live audio。 */ protocol: string /** Play speed。Scope 0.5-2.0。 * @default 1 */ playbackRate?: number /** Length of current audio(Units:s),Only if it's legal. src Back on time.。 * @readonly */ duration: number /** Current audio playing position(Units:s),Only if it's legal. src Back on time.。 * @readonly */ currentTime: number /** Whether or not to suspend stop at present。 * @readonly */ paused: boolean /** Audio buffer time,Only ensure that the current playtime to this time point is buffered。 * @readonly */ buffered: number /** origin: Send Full referrer; no-referrer: Do Not Send */ referrerPolicy?: 'origin' | 'no-referrer' | string /** Play */ play(): void /** Pause */ pause(): void /** Jump to Assigned Location,Units s */ seek(position: any): void /** Stop */ stop(): void /** Background audio access to playable status,But there's no guarantee we'll be able to play in the back. */ onCanplay(callback?: () => void): void /** Audio Loading Events,When audio is not enough because of the data,It triggers when you need to stop loading. */ onWaiting(callback?: () => void): void /** Background audio playout error event */ onError(callback?: () => void): void /** Background audio playout event */ onPlay(callback?: () => void): void /** Background audio pause event */ onPause(callback?: () => void): void /** Background audio starting to jump into operation event */ onSeeking(callback?: () => void): void /** Background audio complete jump operation event */ onSeeked(callback?: () => void): void /** The background audio playout ends naturally */ onEnded(callback?: () => void): void /** Background audio stop event */ onStop(callback?: () => void): void /** Background audio play progress update event */ onTimeUpdate(callback?: () => void): void /** A user clicks on a previous piece of events system music play panel(iOS only) */ onPrev(callback?: () => void): void /** The user clicks the next event on system music play panel(iOS only) */ onNext(callback?: () => void): void } interface VnmfStatic { /** * Stop playing music。 * @supported weapp * @example * ```tsx * Vnmf.stopBackgroundAudio() * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.stopBackgroundAudio.html */ stopBackgroundAudio(option?: stopBackgroundAudio.Option): void /** Control music play progress。 * @supported weapp * @example * ```tsx * Vnmf.seekBackgroundAudio({ * position: 30 * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.seekBackgroundAudio.html */ seekBackgroundAudio(option: seekBackgroundAudio.Option): Promise /** Play music with a back-office player,For the micro-mail client,,There's only one backstage music playing at the same time.。When the user leaves applet,Music will pause;When the user clicks“Show on top of chat”Hour,Music doesn't stop playing.;When the user uses music player in other applets,The music in the old applet will stop playing。 * @supported weapp * @example * ```tsx * Vnmf.playBackgroundAudio({ * dataUrl: '', * title: '', * coverImgUrl: '' * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.playBackgroundAudio.html */ playBackgroundAudio(option: playBackgroundAudio.Option): Promise /** Pause music。 * @supported weapp * @example * ```tsx * Vnmf.pauseBackgroundAudio() * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.pauseBackgroundAudio.html */ pauseBackgroundAudio(option?: pauseBackgroundAudio.Option): void /** Stop listening to music.。 * * **bug & tip:** * * 1. `bug`: `iOS` `6.3.30` Vnmf.seekBackgroundAudio There's a short delay. * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.onBackgroundAudioStop.html */ onBackgroundAudioStop( /** Respond function for music stop-events */ callback: (res: VnmfGeneral.CallbackResult) => void, ): void /** Listen to Music Plays。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.onBackgroundAudioPlay.html */ onBackgroundAudioPlay( /** Echo function for music play events */ callback: (res: VnmfGeneral.CallbackResult) => void, ): void /** Pause listening to music。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.onBackgroundAudioPause.html */ onBackgroundAudioPause( /** Respond function for music pause events */ callback: (res: VnmfGeneral.CallbackResult) => void, ): void /** Retrieve backstage music playing status。 * **Attention.:1.2.0 Version Start,This interface is not maintained。Suggested use of more capable [Vnmf.getBackgroundAudioManager](/docs/apis/media/background-audio/getBackgroundAudioManager) Interface** * @supported weapp * @example * ```tsx * Vnmf.getBackgroundAudioPlayerState({ * success: function (res) { * var status = res.status * var dataUrl = res.dataUrl * var currentPosition = res.currentPosition * var duration = res.duration * var downloadPercent = res.downloadPercent * } * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.getBackgroundAudioPlayerState.html */ getBackgroundAudioPlayerState(option?: getBackgroundAudioPlayerState.Option): Promise /** Fetch**Global only**Background Audio Manager。 * Applets to the backstage.,If audio is playing,You can keep playing.。But the backstage state can't be called.APIManipulate the audio playing state。 * * Could not close temporary folder: %s6.7.2Version Start,If you need to continue playing audio after cut the backstage,,Yes, I do. [app.json](https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html) Cannot initialise Evolution's mail component. `requiredBackgroundModes` Properties。The development and experience versions are directly effective.,The official edition still needs to be cleared.。 * @supported weapp, tt * @example * ```tsx * const backgroundAudioManager = Vnmf.getBackgroundAudioManager() * backgroundAudioManager.title = '♪ Right now, right now' * backgroundAudioManager.epname = '♪ Right now, right now' * backgroundAudioManager.singer = 'Xu Jian.' * backgroundAudioManager.coverImgUrl = 'https://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000' * backgroundAudioManager.src = 'https://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E061FF02C31F716658E5C81F5594D561F2E88B854E81CAAB7806D5E4F103E55D33C16F3FAC506D1AB172DE8600B37E43FAD&fromtag=46' // Set src It'll be played automatically after that. * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.getBackgroundAudioManager.html */ getBackgroundAudioManager(): BackgroundAudioManager } }