|
|
@@ -1,28 +1,57 @@
|
|
|
<!-- -->
|
|
|
<template>
|
|
|
<div v-if="mp3" class="content-voices" @click="handlePlayVoice">
|
|
|
- <img
|
|
|
- :src="voiceSrc"
|
|
|
- :class="type == 'full' ? 'icon-big' : ''"
|
|
|
- class="icon-mask"
|
|
|
- :style="{
|
|
|
- backgroundColor: themeColor,
|
|
|
- maskImage: `url(${voiceSrc})`,
|
|
|
- }"
|
|
|
- />
|
|
|
+ <template v-if="isCompare">
|
|
|
+ <div
|
|
|
+ class="icon-mask icon-compare-play"
|
|
|
+ :style="{
|
|
|
+ backgroundColor: attrib?.topic_color,
|
|
|
+ }"
|
|
|
+ :class="type == 'full' ? 'icon-big' : ''"
|
|
|
+ v-if="isPlaying"
|
|
|
+ ></div>
|
|
|
+ <div
|
|
|
+ class="icon-mask icon-compare-pause"
|
|
|
+ :style="{
|
|
|
+ backgroundColor: attrib?.topic_color,
|
|
|
+ }"
|
|
|
+ :class="type == 'full' ? 'icon-big' : ''"
|
|
|
+ v-else
|
|
|
+ ></div>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <div
|
|
|
+ class="icon-mask icon-normal-play"
|
|
|
+ :style="{
|
|
|
+ backgroundColor: attrib?.topic_color,
|
|
|
+ }"
|
|
|
+ :class="type == 'full' ? 'icon-big' : ''"
|
|
|
+ v-if="isPlaying"
|
|
|
+ ></div>
|
|
|
+ <div
|
|
|
+ class="icon-mask icon-normal-pause"
|
|
|
+ :style="{
|
|
|
+ backgroundColor: attrib?.topic_color,
|
|
|
+ }"
|
|
|
+ :class="type == 'full' ? 'icon-big' : ''"
|
|
|
+ v-else
|
|
|
+ ></div>
|
|
|
+ </template>
|
|
|
+ <!-- <img :src="voiceSrc" :class="type == 'full' ? 'icon-big' : ''" class="icon-mask" :style="maskStyle" /> -->
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
export default {
|
|
|
components: {},
|
|
|
- props: ['seconds', 'mp3', 'wav', 'themeColor', 'isCompare', 'type', 'bg', 'ed'],
|
|
|
+ props: ['seconds', 'mp3', 'wav', 'themeColor', 'isCompare', 'type', 'bg', 'ed', 'attrib'],
|
|
|
data() {
|
|
|
return {
|
|
|
audio: new Audio(),
|
|
|
voiceSrc: '',
|
|
|
voicePauseSrc: require('@/assets/play-red.png'),
|
|
|
voicePlaySrc: require('@/assets/icon-voice-play-red.png'),
|
|
|
+ isPlaying: false,
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -32,6 +61,10 @@ export default {
|
|
|
comparePlaySrc() {
|
|
|
return require('@/assets/icon/pauseC-24-normal-red.png');
|
|
|
},
|
|
|
+ // 通过 mask 把图标着成指定颜色
|
|
|
+ maskStyle() {
|
|
|
+ return {};
|
|
|
+ },
|
|
|
},
|
|
|
watch: {},
|
|
|
// 生命周期 - 创建完成(可以访问当前this实例)
|
|
|
@@ -59,15 +92,18 @@ export default {
|
|
|
_this.audio.addEventListener('play', function () {
|
|
|
_this.voiceSrc = _this.isCompare ? _this.comparePlaySrc : _this.voicePlaySrc;
|
|
|
_this.$emit('getPlayStatus', true);
|
|
|
+ _this.isPlaying = true;
|
|
|
});
|
|
|
_this.audio.addEventListener('pause', function () {
|
|
|
_this.voiceSrc = _this.isCompare ? _this.comparePauseSrc : _this.voicePauseSrc;
|
|
|
_this.$emit('getPlayStatus', false);
|
|
|
+ _this.isPlaying = false;
|
|
|
});
|
|
|
_this.audio.addEventListener('ended', function () {
|
|
|
_this.voiceSrc = _this.isCompare ? _this.comparePauseSrc : _this.voicePauseSrc;
|
|
|
_this.$emit('sentPause', false);
|
|
|
_this.$emit('getPlayStatus', false);
|
|
|
+ _this.isPlaying = false;
|
|
|
});
|
|
|
_this.audio.addEventListener('timeupdate', function () {
|
|
|
if (_this.ed) {
|
|
|
@@ -131,15 +167,32 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- img {
|
|
|
+ img,
|
|
|
+ .icon-mask {
|
|
|
float: left;
|
|
|
- width: 16px;
|
|
|
- height: 16px;
|
|
|
+ width: 20px;
|
|
|
+ height: 20px;
|
|
|
}
|
|
|
|
|
|
.icon-big {
|
|
|
width: 24px;
|
|
|
height: 24px;
|
|
|
}
|
|
|
+
|
|
|
+ .icon-compare-play {
|
|
|
+ mask-image: url('@/assets/icon/pauseC-24-normal-red.png');
|
|
|
+ }
|
|
|
+
|
|
|
+ .icon-compare-pause {
|
|
|
+ mask-image: url('@/assets/compare-pause-red-24.png');
|
|
|
+ }
|
|
|
+
|
|
|
+ .icon-normal-play {
|
|
|
+ mask-image: url('@/assets/icon-voice-play-red.png');
|
|
|
+ }
|
|
|
+
|
|
|
+ .icon-normal-pause {
|
|
|
+ mask-image: url('@/assets/play-red.png');
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|