From 5e179b7c38d40dbfcad105975bba7e56aeb1d6bd Mon Sep 17 00:00:00 2001 From: mahaifeng Date: Mon, 4 Nov 2024 18:00:48 +0800 Subject: [PATCH] =?UTF-8?q?[audio]=E4=BF=AE=E6=94=B9=E9=9F=B3=E9=A2=91?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages.json | 24 ++++++++-------- .../background-audio/background-audio.uvue | 12 ++++---- .../create-inner-audio-context.uvue | 10 +++++-- .../inner-audio-format.uvue | 25 +++++++++-------- .../inner-audio-path.uvue | 28 +++++++++---------- 5 files changed, 54 insertions(+), 45 deletions(-) diff --git a/pages.json b/pages.json index 056138fa..22d9fcd1 100644 --- a/pages.json +++ b/pages.json @@ -1097,16 +1097,16 @@ } }, // #endif - // #ifdef APP - { - "path": "pages/API/background-audio/background-audio", - "group": "1,7,9", - "style": { - "navigationBarTitleText": "backgroundAudio | 背景音乐" - } - }, - // #endif - // #ifdef WEB || MP + // // #ifdef APP + // { + // "path": "pages/API/background-audio/background-audio", + // "group": "1,7,10", + // "style": { + // "navigationBarTitleText": "backgroundAudio | 背景音乐" + // } + // }, + // // #endif + // #ifdef WEB || MP || APP { "path": "pages/API/create-inner-audio-context/create-inner-audio-context", "group": "1,7,9", @@ -1116,7 +1116,7 @@ }, // #endif - // #ifdef WEB || MP + // #ifdef WEB || MP || APP { "path": "pages/API/create-inner-audio-context/inner-audio-format", "style": { @@ -1124,7 +1124,7 @@ } }, // #endif - // #ifdef WEB || MP + // #ifdef WEB || MP ||APP { "path": "pages/API/create-inner-audio-context/inner-audio-path", "style": { diff --git a/pages/API/background-audio/background-audio.uvue b/pages/API/background-audio/background-audio.uvue index 4b9d10e7..dc02b74b 100644 --- a/pages/API/background-audio/background-audio.uvue +++ b/pages/API/background-audio/background-audio.uvue @@ -68,7 +68,7 @@ bgAudioMannager.title = '致爱丽丝'+this.count++; bgAudioMannager.singer = '暂无2'+this.count++; bgAudioMannager.coverImgUrl = 'https://web-assets.dcloud.net.cn/unidoc/zh/Alice.jpeg'; - this.bgAudioMannager!!.src = this.dataUrl; + this.bgAudioMannager!.src = this.dataUrl; this.bgAudioMannager?.play() }) bgAudioMannager.onPrev(() => { @@ -76,7 +76,7 @@ this.bgAudioMannager?.stop() bgAudioMannager.title = '致爱丽丝'+this.count--; bgAudioMannager.singer = '暂无'+this.count--; - this.bgAudioMannager!!.src = this.dataUrl; + this.bgAudioMannager!.src = this.dataUrl; this.bgAudioMannager?.play() }) // bgAudioMannager.onTimeUpdate((e) => { @@ -91,17 +91,17 @@ methods: { play: function () { console.log('play') - this.bgAudioMannager!!.src = this.dataUrl; + this.bgAudioMannager!.src = this.dataUrl; // #ifdef APP-ANDROID if (UTSAndroid.checkSystemPermissionGranted(UTSAndroid.getUniActivity()!, ["android.permission.POST_NOTIFICATIONS"])) { - this.bgAudioMannager!!.play() + this.bgAudioMannager!.play() } else { // 检查当前 Android 版本和 targetSdkVersion if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { // Android 13 及以上版本 if ((UTSAndroid.getAppContext() as Application).applicationInfo.targetSdkVersion >= 33) { UTSAndroid.requestSystemPermission(UTSAndroid.getUniActivity()!, ["android.permission.POST_NOTIFICATIONS"], (_ : boolean, p : string[]) => { - this.bgAudioMannager!!.play() + this.bgAudioMannager!.play() }, (_ : boolean, p : string[]) => { uni.showToast({ title: "权限被拒绝了", @@ -178,4 +178,4 @@ flex-direction: row; justify-content: center; } - \ No newline at end of file + diff --git a/pages/API/create-inner-audio-context/create-inner-audio-context.uvue b/pages/API/create-inner-audio-context/create-inner-audio-context.uvue index 93d272a5..d3f36be4 100644 --- a/pages/API/create-inner-audio-context/create-inner-audio-context.uvue +++ b/pages/API/create-inner-audio-context/create-inner-audio-context.uvue @@ -1,4 +1,7 @@