plus.android.requestPermissions(
["android.permission.READ_EXTERNAL_STORAGE", "android.permission.WRITE_EXTERNAL_STORAGE"],
function (result) {
let filePath = plus.io.convertLocalFileSystemURL(`/storage/76FB-CFA0/oyuuntApp/1/1/1_1t.mp3`)
let fs = plus.io.resolveLocalFileSystemURL;
fs(filePath, function(entry) {
// 如果成功获取了文件入口,那么文件存在
console.log("文件存在: " + filePath);
const innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.src = filePath;
innerAudioContext.onPlay(() => {
console.log('开始播放');
});
innerAudioContext.onError((res) => {
console.log(res.errMsg);
console.log(res.errCode);
});
}, function(error) {
// 如果发生错误,通常意味着文件不存在
console.error("文件不存在或无法访问: " + filePath);
});
console.log("权限申请结果:", result);
},
function (error) {
console.error("权限申请失败:", error);
}
);
12:06:54.388 权限申请结果:, [Object] {"granted":["android.permission.READ_EXTERNAL_STORAGE","android.permission.WRITE_EXTERNAL_S...} at pages/index/index.vue:254
12:06:54.406 文件存在: /storage/76FB-CFA0/oyuuntApp/1/1/1_1t.mp3 at pages/index/index.vue:234
12:06:54.473 MediaError at pages/index/index.vue:244
12:06:54.473 [Number] -5 at pages/index/index.vue:245
0 个回复