Browse Source

音频播放开始ios静音播放

jwyu 2 năm trước cách đây
mục cha
commit
97daa8c8f7
3 tập tin đã thay đổi với 22 bổ sung2 xóa
  1. 5 0
      App.vue
  2. 1 0
      pages-voice/addVoice.vue
  3. 16 2
      pages/voice/voice.vue

+ 5 - 0
App.vue

@@ -25,6 +25,11 @@
 				fail:function(res){
 				fail:function(res){
 				}
 				}
 			})
 			})
+
+			// 开启ios静音也行播放语音
+			wx.setInnerAudioOption({
+				obeyMuteSwitch:false
+			})
 		},
 		},
 		onShow: function(options) {
 		onShow: function(options) {
 			console.log('App Show')
 			console.log('App Show')

+ 1 - 0
pages-voice/addVoice.vue

@@ -298,6 +298,7 @@ export default {
         //点击播放\暂停音频
         //点击播放\暂停音频
         handlePlayAudio(){
         handlePlayAudio(){
             innerAudioContext.src=this.temAudio.url
             innerAudioContext.src=this.temAudio.url
+            innerAudioContext.obeyMuteSwitch=false
             if(this.temAudio.paused){
             if(this.temAudio.paused){
                 innerAudioContext.play()
                 innerAudioContext.play()
             }else{
             }else{

+ 16 - 2
pages/voice/voice.vue

@@ -24,7 +24,9 @@
                     <text v-if="item.BroadcastId==temAudio.id">{{temAudio.curTime|formatVoiceTime}}</text>
                     <text v-if="item.BroadcastId==temAudio.id">{{temAudio.curTime|formatVoiceTime}}</text>
                     <text v-else>{{item.VoicePlaySeconds|formatVoiceTime}}</text>
                     <text v-else>{{item.VoicePlaySeconds|formatVoiceTime}}</text>
                 </view>
                 </view>
-                <image class="del-btn" src="@/static/voice/del.png" @click="handleDelItem(item)" mode="widthFix" v-if="item.IsAuthor" />
+                <button class="del-btn">
+                <image class="del-img" src="@/static/voice/del.png" @click="handleDelItem(item)" mode="widthFix" v-if="item.IsAuthor" />
+                </button>
                 <button 
                 <button 
                     class="share-btn" 
                     class="share-btn" 
                     open-type="share" 
                     open-type="share" 
@@ -318,6 +320,7 @@ export default {
                 this.temAudio.duration=item.VoicePlaySeconds
                 this.temAudio.duration=item.VoicePlaySeconds
                 this.temAudio.curTime=item.VoicePlaySeconds
                 this.temAudio.curTime=item.VoicePlaySeconds
                 innerAudioContext.src=item.VoiceUrl 
                 innerAudioContext.src=item.VoiceUrl 
+                innerAudioContext.obeyMuteSwitch=false
                 innerAudioContext.play()
                 innerAudioContext.play()
                 this.handleVoicePlayRecord(item)
                 this.handleVoicePlayRecord(item)
             }
             }
@@ -444,10 +447,21 @@ export default {
         .del-btn{
         .del-btn{
             position: absolute;
             position: absolute;
             right: 130rpx;
             right: 130rpx;
-            bottom: 34rpx;
+            bottom: 30rpx;
+            width: 36rpx;
+            height: 36rpx;
+            background-color: transparent;
+            line-height: 1;
+            padding: 0;
+            &::after{
+                border: none;
+            }
+        }
+        .del-img{
             width: 34rpx;
             width: 34rpx;
             height: 34rpx;
             height: 34rpx;
         }
         }
+
         .share-btn{
         .share-btn{
             position: absolute;
             position: absolute;
             bottom: 30rpx;
             bottom: 30rpx;