|
@@ -14,6 +14,7 @@ export default {
|
14
|
14
|
return {
|
15
|
15
|
playing: 'off',
|
16
|
16
|
audio: null,
|
|
17
|
+ trigger: 'ontouchend' in window.document ? 'touchstart' : 'click',
|
17
|
18
|
|
18
|
19
|
icons: {
|
19
|
20
|
'1': {
|
|
@@ -30,11 +31,24 @@ export default {
|
30
|
31
|
watch: {
|
31
|
32
|
url: function(n) {
|
32
|
33
|
if (this.playing === 'off' && n) {
|
|
34
|
+ // 自动播放
|
33
|
35
|
window.setTimeout(this.play, 1000)
|
|
36
|
+
|
|
37
|
+ // 手动触发音乐播放
|
|
38
|
+ // IOS 不允许自动播放
|
|
39
|
+ window.document.addEventListener(this.trigger, this.autoplay, false)
|
34
|
40
|
}
|
35
|
41
|
}
|
36
|
42
|
},
|
37
|
43
|
methods: {
|
|
44
|
+ autoplay() {
|
|
45
|
+ document.removeEventListener(this.trigger, this.autoplay, false)
|
|
46
|
+
|
|
47
|
+ if (this.playing === 'off') {
|
|
48
|
+ this.play()
|
|
49
|
+ }
|
|
50
|
+ },
|
|
51
|
+
|
38
|
52
|
play() {
|
39
|
53
|
if (this.url) {
|
40
|
54
|
if (!this.audio) {
|