|
@@ -2,7 +2,7 @@
|
|
|
<view class="container global-audio-box" v-if="showAudioPop">
|
|
|
<view class="bg-overlay" @click="isShowMaskHandler"></view>
|
|
|
<view class="audio-box">
|
|
|
- <view class="activity-title text_oneLine">
|
|
|
+ <view class="activity-title">
|
|
|
{{ activityTitle }}
|
|
|
<view class="icon-cross" @click.stop="isShowMaskHandler">
|
|
|
<van-icon name="cross" font-size="32" />
|
|
@@ -12,17 +12,38 @@
|
|
|
<view class="card-title text_oneLine">
|
|
|
{{ title }}
|
|
|
</view>
|
|
|
- <slider activeColor="#3385FF" :max="audioTime" :value="curTime" @change="handleAudioSliderChange($event)" block-size="16" class="slider" />
|
|
|
- <view class="card-time">
|
|
|
- <text class="time">{{ curTime | formatVoiceTime }}</text>
|
|
|
- <text class="time">{{ audioTime | formatVoiceTime }}</text>
|
|
|
+ <view class="slider-paly">
|
|
|
+ <view style="flex: 1; padding-top: 20rpx">
|
|
|
+ <slider
|
|
|
+ activeColor="#3385FF"
|
|
|
+ :max="audioTime"
|
|
|
+ :value="curTime"
|
|
|
+ @touchstart="touchstartHandler"
|
|
|
+ @change="handleAudioSliderChange($event)"
|
|
|
+ @changing="handleAudioSliderChangeing($event)"
|
|
|
+ block-size="16"
|
|
|
+ class="slider"
|
|
|
+ />
|
|
|
+ <view class="card-time">
|
|
|
+ <text class="time">{{ curTime | formatVoiceTime }}</text>
|
|
|
+ <text class="time">{{ audioTime | formatVoiceTime }}</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="is-paly-card">
|
|
|
+ <image
|
|
|
+ @click.stop="handleChangePlayStatus"
|
|
|
+ :src="play ? 'https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/play_icon.gif' : 'https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/pause_icon.png'"
|
|
|
+ ></image>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
- <view class="is-paly-card">
|
|
|
- <image
|
|
|
- @click.stop="handleChangePlayStatus"
|
|
|
- class=""
|
|
|
- :src="play ? 'https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/suspend_icon.png' : 'https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/play_icon.png'"
|
|
|
- ></image>
|
|
|
+ <view class="fast-reverse">
|
|
|
+ <image @click="speedReverseHandler('reverse')" class="speed-img" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/fastReverse_icon.png"></image>
|
|
|
+ <block v-for="(item, index) in timesTheSpeed" :key="item.value">
|
|
|
+ <view class="speed-button" v-if="isTimes == item.value" @click="isTimesHandler(index)">
|
|
|
+ {{ item.name }}
|
|
|
+ </view>
|
|
|
+ </block>
|
|
|
+ <image @click="speedReverseHandler('speed')" class="speed-img" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/speed_icon.png"></image>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -55,16 +76,34 @@ export default {
|
|
|
title: "", //当前音频标题
|
|
|
activityTitle: "", //当前活动标题
|
|
|
play: false,
|
|
|
- isEnded: false,
|
|
|
+ isosName: "",
|
|
|
+ timesTheSpeed: [
|
|
|
+ { name: "倍速", value: 1 },
|
|
|
+ { name: "1.25倍", value: 1.25 },
|
|
|
+ { name: "1.5倍", value: 1.5 },
|
|
|
+ { name: "2倍", value: 2 },
|
|
|
+ ],
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
+ //重新
|
|
|
audioInit() {
|
|
|
return {
|
|
|
activityId: this.$store.state.audioBg.activityId,
|
|
|
reportId: this.$store.state.audioBg.reportId,
|
|
|
};
|
|
|
},
|
|
|
+ // 几倍的播放速度
|
|
|
+ isTimes() {
|
|
|
+ return this.$store.state.audioBg.multiple;
|
|
|
+ },
|
|
|
+ //进度条是否在滑动
|
|
|
+ isSlide() {
|
|
|
+ return this.$store.state.audioBg.isDragSlide;
|
|
|
+ },
|
|
|
+ isEnded() {
|
|
|
+ return this.$store.state.audioBg.isAudioEnded;
|
|
|
+ },
|
|
|
},
|
|
|
watch: {
|
|
|
audioInit: {
|
|
@@ -77,7 +116,11 @@ export default {
|
|
|
|
|
|
created() {},
|
|
|
mounted() {
|
|
|
- this.init();
|
|
|
+ uni.getSystemInfo({
|
|
|
+ success: (res) => {
|
|
|
+ this.isosName = res.osName;
|
|
|
+ },
|
|
|
+ });
|
|
|
},
|
|
|
methods: {
|
|
|
//点击隐藏事件
|
|
@@ -87,81 +130,118 @@ export default {
|
|
|
//数据初次加载
|
|
|
init() {
|
|
|
const curAudio = this.$store.state.audioBg.list;
|
|
|
- if (this.globalBgAudioManager.src != curAudio.Url) {
|
|
|
+ if ((this.globalBgAudioManager.src != curAudio.Url && curAudio.Url) || (this.isEnded && this.isosName !== "ios" && curAudio.Url)) {
|
|
|
+ this.$store.commit("audioBg/setAudioEnd", false);
|
|
|
+ this.globalBgAudioManager.playbackRate = 1;
|
|
|
+ this.$store.commit("audioBg/setMultiple", 1);
|
|
|
+ this.$store.commit("audioBg/updateAudioTime", 0);
|
|
|
this.globalBgAudioManager.src = curAudio.Url;
|
|
|
this.globalBgAudioManager.title = curAudio.Name;
|
|
|
+ this.globalBgAudioManager.startTime = 0;
|
|
|
+ this.curTime = 0;
|
|
|
+ } else {
|
|
|
+ this.curTime = parseInt(this.globalBgAudioManager.currentTime);
|
|
|
}
|
|
|
this.audioTime = curAudio.PlaySeconds;
|
|
|
this.title = curAudio.Name;
|
|
|
this.activityTitle = this.$store.state.audioBg.activityTitle;
|
|
|
- this.curTime = parseInt(this.globalBgAudioManager.currentTime);
|
|
|
this.play = !this.globalBgAudioManager.paused;
|
|
|
this.listenAudio();
|
|
|
},
|
|
|
//音频播放事件
|
|
|
listenAudio() {
|
|
|
this.globalBgAudioManager.onPlay(async () => {
|
|
|
+ console.log("音频播放");
|
|
|
this.play = true;
|
|
|
this.$store.commit("audioBg/updateAudioPause", false);
|
|
|
if (this.$store.state.audioBg.activityId) {
|
|
|
activity.backAudioPlay({ ActivityId: this.$store.state.audioBg.activityId });
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
this.globalBgAudioManager.onPause(() => {
|
|
|
console.log("音频暂停");
|
|
|
this.play = false;
|
|
|
this.$store.commit("audioBg/updateAudioPause", true);
|
|
|
});
|
|
|
+
|
|
|
this.globalBgAudioManager.onStop(() => {
|
|
|
console.log("音频停止");
|
|
|
- uni.getSystemInfo({
|
|
|
- success: (res) => {
|
|
|
- if (res.osName == "ios") {
|
|
|
- console.log("ios");
|
|
|
- this.$store.commit("audioBg/removeAudio");
|
|
|
- } else {
|
|
|
- this.play = false;
|
|
|
- this.$store.commit("audioBg/updateAudioPause", true);
|
|
|
- }
|
|
|
- },
|
|
|
- });
|
|
|
+ this.$emit("update:showAudioPop", false);
|
|
|
+ if (this.isosName == "ios") {
|
|
|
+ this.play = false;
|
|
|
+ this.$store.commit("audioBg/removeAudio");
|
|
|
+ } else {
|
|
|
+ this.play = false;
|
|
|
+ this.$store.commit("audioBg/updateAudioPause", true);
|
|
|
+ }
|
|
|
});
|
|
|
+
|
|
|
this.globalBgAudioManager.onEnded(() => {
|
|
|
console.log("音频onEnded");
|
|
|
- this.play = false;
|
|
|
- this.$store.commit("audioBg/updateAudioPause", true);
|
|
|
+ this.$emit("update:showAudioPop", false);
|
|
|
+ this.$store.commit("audioBg/setAudioEnd", true);
|
|
|
+ this.$store.commit("audioBg/parseIntAudio", false);
|
|
|
+ this.$store.commit("audioBg/removeAudio");
|
|
|
});
|
|
|
+
|
|
|
this.globalBgAudioManager.onError((e) => {
|
|
|
console.log("音频onError", e);
|
|
|
this.$store.commit("audioBg/removeAudio");
|
|
|
+ this.$store.commit("audioBg/setMultiple", 1);
|
|
|
uni.showToast({
|
|
|
title: "音频播放错误",
|
|
|
icon: "none",
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
//音频的播放时间更新
|
|
|
this.globalBgAudioManager.onTimeUpdate(() => {
|
|
|
- this.curTime = parseInt(this.globalBgAudioManager.currentTime);
|
|
|
- this.$store.commit("audioBg/updateAudioTime", this.curTime);
|
|
|
+ if (this.globalBgAudioManager.src && parseInt(this.globalBgAudioManager.currentTime) !== 0 && !this.isSlide) {
|
|
|
+ this.curTime = parseInt(this.globalBgAudioManager.currentTime);
|
|
|
+ this.$store.commit("audioBg/updateAudioTime", this.curTime);
|
|
|
+ }
|
|
|
});
|
|
|
},
|
|
|
//拖动进度条
|
|
|
+ handleAudioSliderChangeing(e) {
|
|
|
+ this.curTime = e.detail.value;
|
|
|
+ },
|
|
|
+ //拖动进度条
|
|
|
handleAudioSliderChange(e) {
|
|
|
const value = e.detail.value;
|
|
|
this.globalBgAudioManager.seek(value);
|
|
|
+ setTimeout(() => {
|
|
|
+ this.$store.commit("audioBg/setSlide", false);
|
|
|
+ }, 300);
|
|
|
},
|
|
|
//音频点击暂停播放
|
|
|
handleChangePlayStatus() {
|
|
|
- if (this.globalBgAudioManager.src) {
|
|
|
- if (!this.globalBgAudioManager.paused) {
|
|
|
- this.globalBgAudioManager.pause();
|
|
|
- } else {
|
|
|
- this.globalBgAudioManager.play();
|
|
|
- }
|
|
|
+ if (!this.globalBgAudioManager.paused) {
|
|
|
+ this.globalBgAudioManager.pause();
|
|
|
} else {
|
|
|
- this.init();
|
|
|
+ this.globalBgAudioManager.play();
|
|
|
}
|
|
|
},
|
|
|
+ //倍速播放
|
|
|
+ isTimesHandler(i) {
|
|
|
+ let index = i == 3 ? 0 : i + 1;
|
|
|
+ this.$store.commit("audioBg/setMultiple", this.timesTheSpeed[index].value);
|
|
|
+ this.globalBgAudioManager.playbackRate = this.isTimes;
|
|
|
+ this.globalBgAudioManager.startTime = this.curTime;
|
|
|
+ if (this.globalBgAudioManager.paused) {
|
|
|
+ this.globalBgAudioManager.play();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //快进 快退
|
|
|
+ speedReverseHandler(type) {
|
|
|
+ let isTime = type == "reverse" ? this.curTime - 15 : this.curTime + 15;
|
|
|
+ isTime = isTime <= 0 ? 0 : isTime >= this.audioTime ? this.audioTime - 1 : isTime;
|
|
|
+ this.globalBgAudioManager.seek(isTime);
|
|
|
+ },
|
|
|
+ touchstartHandler() {
|
|
|
+ this.$store.commit("audioBg/setSlide", true);
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
@@ -188,7 +268,6 @@ export default {
|
|
|
font-size: 30rpx;
|
|
|
font-weight: 500;
|
|
|
margin-bottom: 35rpx;
|
|
|
- text-align: center;
|
|
|
padding-right: 30rpx;
|
|
|
.icon-cross {
|
|
|
position: absolute;
|
|
@@ -202,19 +281,18 @@ export default {
|
|
|
position: absolute;
|
|
|
bottom: 0;
|
|
|
left: 0;
|
|
|
+ padding: 30rpx;
|
|
|
padding-bottom: constant(safe-area-inset-bottom);
|
|
|
padding-bottom: env(safe-area-inset-bottom);
|
|
|
width: 100%;
|
|
|
- height: 460rpx;
|
|
|
background: #ffffff;
|
|
|
- padding: 30rpx;
|
|
|
box-sizing: border-box;
|
|
|
border-radius: 30rpx 30rpx 0 0;
|
|
|
}
|
|
|
.audio-card {
|
|
|
width: 100%;
|
|
|
height: 282rpx;
|
|
|
- background: #f5f9ff;
|
|
|
+ background: #f9f9f9;
|
|
|
border-radius: 16rpx;
|
|
|
margin: 0 auto;
|
|
|
padding: 30rpx;
|
|
@@ -222,10 +300,15 @@ export default {
|
|
|
width: 100%;
|
|
|
margin: 0;
|
|
|
}
|
|
|
+ .slider-paly {
|
|
|
+ display: flex;
|
|
|
+ height: 80rpx;
|
|
|
+ align-items: center;
|
|
|
+ }
|
|
|
.card-title {
|
|
|
color: #3385ff;
|
|
|
font-size: 28rpx;
|
|
|
- padding: 0 66rpx;
|
|
|
+ padding: 0 40rpx;
|
|
|
text-align: center;
|
|
|
margin-bottom: 35rpx;
|
|
|
}
|
|
@@ -236,12 +319,32 @@ export default {
|
|
|
font-size: 20rpx;
|
|
|
}
|
|
|
.is-paly-card {
|
|
|
- width: 100%;
|
|
|
- text-align: center;
|
|
|
+ width: 70rpx;
|
|
|
+ height: 70rpx;
|
|
|
+ flex-shrink: 0;
|
|
|
+ margin-left: 30rpx;
|
|
|
image {
|
|
|
- margin-top: 5rpx;
|
|
|
- width: 100rpx;
|
|
|
- height: 100rpx;
|
|
|
+ width: 70rpx;
|
|
|
+ height: 70rpx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .fast-reverse {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ margin-top: 30rpx;
|
|
|
+ .speed-button {
|
|
|
+ width: 96rpx;
|
|
|
+ height: 47rpx;
|
|
|
+ background: #eaeaea;
|
|
|
+ border-radius: 8rpx;
|
|
|
+ text-align: center;
|
|
|
+ line-height: 47rpx;
|
|
|
+ margin: 0 70rpx;
|
|
|
+ }
|
|
|
+ .speed-img {
|
|
|
+ width: 50rpx;
|
|
|
+ height: 50rpx;
|
|
|
}
|
|
|
}
|
|
|
}
|