HomeDocs
Skip to main content

getForegroundAudioOption

Introduction

Get the value of a parameter for an audio task.

Parameters

AttributeTypeRequiredDescription
audioPlayerIDStringYesThe unique identifier of the audio task.
optionNameStringYesThe name of the parameter to retrieve.
successFunctionNoThe callback function to execute when the API call is successful.
failFunctionNoThe callback function to execute when the API call fails.
completeFunctionNoThe callback function to execute when the API call ends (whether successful or failed).

Available optionName values:

AttributeTypeDescription
srcStringThe source address of the audio; local file paths only support absolute paths.
loopBooleanWhether to loop the playback.
autoPlayBooleanWhether to enable auto playback.
volumeNumberThe volume level; range from 0 to 1.
startTimeNumberThe starting position of the playback, in seconds. Default is 0.
durationNumberThe duration of the current audio, in seconds.
bufferedNumberThe time point of the audio buffer; only guarantees that content is buffered until this time point.
pausedBooleanWhether the audio is paused.
currentTimeNumberThe current position of the audio playback, in seconds.

Return Value

AttributeDescription
optionNameDepends on the specific option.

Example

// pages/index/index.js
Page({
getForegroundAudioOption() {
dlt.getForegroundAudioOption({
audioPlayerID: 'bgmId',
optionName: 'src',
success: function (res) {
console.log('success', res);
},
fail: function () {
console.log('fail');
},
complete: function () {
console.log('complete');
},
});
},
});
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.