音频开关以及自动播放
This commit is contained in:
parent
7b6863f3f1
commit
719feb03fc
|
|
@ -25,17 +25,16 @@
|
||||||
<view class="tubiao">
|
<view class="tubiao">
|
||||||
<view class="audio-controls">
|
<view class="audio-controls">
|
||||||
<image
|
<image
|
||||||
v-if="pageConfig.topIcons.leftIcon.hidden"
|
v-if="isAudioPlaying"
|
||||||
:class="{ playing: isAudioPlaying }"
|
|
||||||
:src="pageConfig.topIcons.leftIcon.img"
|
:src="pageConfig.topIcons.leftIcon.img"
|
||||||
mode=""
|
mode=""
|
||||||
@click="playAudio"
|
@click="toggleAudio"
|
||||||
></image>
|
></image>
|
||||||
<image
|
<image
|
||||||
:class="{ stopped: !isAudioPlaying }"
|
v-if="!isAudioPlaying"
|
||||||
:src="pageConfig.topIcons.rightIcon.img"
|
:src="pageConfig.topIcons.rightIcon.img"
|
||||||
mode=""
|
mode=""
|
||||||
@click="stopAudio"
|
@click="toggleAudio"
|
||||||
></image>
|
></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="tubiao-item">
|
<view class="tubiao-item">
|
||||||
|
|
@ -155,7 +154,7 @@ export default {
|
||||||
endTime: "",
|
endTime: "",
|
||||||
audioUrl: "",
|
audioUrl: "",
|
||||||
},
|
},
|
||||||
isAudioPlaying: false,
|
isAudioPlaying: true, // 改为默认开启
|
||||||
audioContext: null,
|
audioContext: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
@ -296,6 +295,11 @@ export default {
|
||||||
this.stopMarquee();
|
this.stopMarquee();
|
||||||
this.startMarquee();
|
this.startMarquee();
|
||||||
|
|
||||||
|
// 自动播放音频
|
||||||
|
if (this.templeData.audioUrl) {
|
||||||
|
this.playAudio();
|
||||||
|
}
|
||||||
|
|
||||||
console.log("寺庙数据加载成功");
|
console.log("寺庙数据加载成功");
|
||||||
} else {
|
} else {
|
||||||
throw new Error("寺庙数据API响应无效");
|
throw new Error("寺庙数据API响应无效");
|
||||||
|
|
@ -442,6 +446,17 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 切换音频播放状态
|
||||||
|
*/
|
||||||
|
toggleAudio() {
|
||||||
|
if (this.isAudioPlaying) {
|
||||||
|
this.stopAudio();
|
||||||
|
} else {
|
||||||
|
this.playAudio();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 播放音频
|
* 播放音频
|
||||||
*/
|
*/
|
||||||
|
|
@ -716,14 +731,6 @@ page {
|
||||||
transform: scale(0.9);
|
transform: scale(0.9);
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.playing {
|
|
||||||
animation: pulse 2s infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.stopped {
|
|
||||||
opacity: 0.6;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user