HomeDocs
Skip to main content

setForegroundAudioOption

Introduction

Set parameters.

Input Parameters

AttributeTypeRequiredDescription
audioPlayerIDStringYesUnique identifier for the audio task.
optionObjectYesData for the audio parameters to be set.
successFunctionNoCallback function for a successful call.
failFunctionNoCallback function for an unsuccessful call.
completeFunctionNoCallback function for the completion of the call (executed for both successful and unsuccessful calls).

Format of the 'option' Data

AttributeTypeDescription
srcStringSource address for playback;
Local file paths support only absolute paths, not relative paths.
loopBooleanWhether to loop playback.
autoPlayBooleanWhether to enable automatic playback.
volumeNumberVolume; valid range (0 to 1).

Usage Example

// pages/index/index.js
Page({
setForegroundAudioOption() {
dlt.setForegroundAudioOption({
audioPlayerID: "bgmId",
option: {
src: "xxx",
loop: true,
autoPlay: true,
volume: 0.4,
},
success: function () {
console.log("success");
},
fail: function () {
console.log("fail");
},
complete: function () {
console.log("complete");
},
});
},
});
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.