Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 30 additions & 30 deletions Api-Example/pages/examples/playMusic/index.nvue
Original file line number Diff line number Diff line change
Expand Up @@ -80,35 +80,35 @@
title: '请填写 sdkAppId、userSig',
icon: 'none'
});
}
}

// 保存音频文件到本地: https://zh.uniapp.dcloud.io/api/file/file.html#savefile
// const tempFilePath = '../../../static/rain.mp3';
// uni.saveFile({
// tempFilePath: tempFilePath,
// success: (res) => {
// console.warn('--- save 成功 = ', JSON.stringify(res)); // 获取的是相对路径
// console.warn('--- save 成功 = ', JSON.stringify(res)); // 获取的是相对路径
// plus
// },
// });

// });
const androidPath = '_doc/uniapp_save/16723976767290.mp3'; // 通过 uni.saveFile 获取的相对路径
const iosPath = '_doc/uniapp_save/16723970195190.mp3'; // 通过 uni.saveFile 获取的相对路径
const info = uni.getSystemInfo({
success: (res) => {
let path = '';
if (res.platform === 'ios') {
path = plus.io.convertLocalFileSystemURL(iosPath); // 转绝对路径
}
if (res.platform === 'android') {
path = plus.io.convertLocalFileSystemURL(androidPath); // 转绝对路径
}
this.musicFilePath = path;
this.musicFilePath = 'https://web.sdk.qcloud.com/component/TUIKit/assets/uni-app/calling-bell-1.mp3'; // 网路路径
}
})

// 【1】创建实例
const iosPath = '_doc/uniapp_save/16723970195190.mp3'; // 通过 uni.saveFile 获取的相对路径
const info = uni.getSystemInfo({
success: (res) => {
let path = '';
if (res.platform === 'ios') {
path = plus.io.convertLocalFileSystemURL(iosPath); // 转绝对路径
}
if (res.platform === 'android') {
path = plus.io.convertLocalFileSystemURL(androidPath); // 转绝对路径
}
this.musicFilePath = path;
this.musicFilePath = 'https://web.sdk.qcloud.com/component/TUIKit/assets/uni-app/calling-bell-1.mp3'; // 网路路径
}
})
// 【1】创建实例
this.createTrtcCloud();
},
unmounted() {
Expand Down Expand Up @@ -205,7 +205,7 @@
isShortFile: false,
startTimeMS: 0,
endTimeMS: 0,
};
};
this.trtcCloud.startPlayMusic(musicParam);
},
pausePlayMusic() {
Expand All @@ -231,15 +231,15 @@
title: `error: ${JSON.stringify(res)}`,
icon: 'none',
});
});
this.trtcCloud.on('onStart', (res) => {
console.log('- onStart: ', JSON.stringify(res));
});
this.trtcCloud.on('onPlayPrograss', (res) => {
console.log('- onPlayPrograss: ', JSON.stringify(res));
});
this.trtcCloud.on('onComplete', (res) => {
console.log('- onComplete: ', JSON.stringify(res));
});
this.trtcCloud.on('onStart', (res) => {
console.log('- onStart: ', JSON.stringify(res));
});
this.trtcCloud.on('onPlayProgress', (res) => {
console.log('- onPlayProgress: ', JSON.stringify(res));
});
this.trtcCloud.on('onComplete', (res) => {
console.log('- onComplete: ', JSON.stringify(res));
});
this.trtcCloud.on('onEnterRoom', (result) => {
console.log(`- onEnterRoom = ${result}`);
Expand Down