Skip to content

Commit

Permalink
add audio
Browse files Browse the repository at this point in the history
  • Loading branch information
vito committed Jan 2, 2020
1 parent c85c64a commit 73cbe31
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
- 本抽奖程序无暗箱操作,无后台,无后门。
- 名单和照片显示只需导入一种即可,无导入数据则使用抽奖号码。
- 建议使用最新的 Chrome 浏览器打开体验最佳。
- 由于背景游戏音乐加载较慢,可以在抽奖前提前打开缓存好。

## License

Expand Down
17 changes: 13 additions & 4 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,15 @@
</div>
</transition>

<el-button class="audio" type="text" @click="audioPlaying = !audioPlaying">
<el-button
class="audio"
type="text"
@click="
() => {
playAudio(!audioPlaying);
}
"
>
<i
class="iconfont"
:class="[audioPlaying ? 'iconstop' : 'iconplay1']"
Expand Down Expand Up @@ -96,6 +104,7 @@
autoplay
loop
@play="playHandler"
@pause="pauseHandler"
>
<source :src="audioSrc" />
你的浏览器不支持audio标签
Expand Down Expand Up @@ -231,9 +240,6 @@ export default {
this.reloadTagCanvas();
});
}
},
audioPlaying(v) {
this.playAudio(v);
}
},
mounted() {
Expand All @@ -246,6 +252,9 @@ export default {
playHandler() {
this.audioPlaying = true;
},
pauseHandler() {
this.audioPlaying = false;
},
playAudio(type) {
if (type) {
this.$el.querySelector('#audiobg').play();
Expand Down

0 comments on commit 73cbe31

Please sign in to comment.