setForegroundAudioOption
Introduction
Set parameters.
Input Parameters
Attribute | Type | Required | Description |
---|---|---|---|
audioPlayerID | String | Yes | Unique identifier for the audio task. |
option | Object | Yes | Data for the audio parameters to be set. |
success | Function | No | Callback function for a successful call. |
fail | Function | No | Callback function for an unsuccessful call. |
complete | Function | No | Callback function for the completion of the call (executed for both successful and unsuccessful calls). |
Format of the 'option' Data
Attribute | Type | Description |
---|---|---|
src | String | Source address for playback; Local file paths support only absolute paths, not relative paths. |
loop | Boolean | Whether to loop playback. |
autoPlay | Boolean | Whether to enable automatic playback. |
volume | Number | Volume; 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");
},
});
},
});