1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<template>
<el-row style="background: #000;">
<audio ref="audio" :src="music_path" loop="loop">
<!-- <source src="" type="audio/wav">-->
<!-- <source src="" type="audio/mpeg">-->
<!-- <source src="http://sc1.111ttt.cn/2018/1/03/13/396131232171.mp3" type="audio/mpeg">-->
<!-- controls class="btn-audio"-->
<!--<source :src="recordUrl" type="audio/mpeg">-->
</audio>
<button type="button" @click="reloadYP">{{buttonText}}</button>
</el-row>
</template>
<style></style>
<script>
// import fngmp3 from "@/assets/mp3/fng.mp3";
export default {
data () {
return {
msg: 'vue模板页',
buttonText:'stop',
music_path: 'http://sc1.111ttt.cn/2018/1/03/13/396131229550.mp3',
}
},
mounted: function(){
this.reloadYP();
},
methods: {
reloadYP () {
this.$refs.audio.src = 'http://sc1.111ttt.cn/2018/1/03/13/396131232171.mp3';
//this.$refs.audio.src = fngmp3;
console.log(this.music_path);
console.log('hello');
// this.music_path = 'http://sc1.111ttt.cn/2018/1/03/13/396131232171.mp3';
if (this.is_play) {
this.$refs['audio'].pause();
this.is_play = false
this.buttonText = 'stopped'
} else {
this.$refs['audio'].play();
this.is_play = true
this.buttonText = 'starting'
}
},
}
}
</script>