Skip to content
This repository was archived by the owner on Jun 9, 2022. It is now read-only.
This repository was archived by the owner on Jun 9, 2022. It is now read-only.

use fastclick in vue project, audio cannot play correctly in ios #586

@xuxiaoxiao312

Description

@xuxiaoxiao312

my app.vue code

<template>
<div id='app' style="width:300px;height:300px;background:#ff0000;margin:10px" @click="togglePlay">
   PLAY WITH {{audioState}}
  </p>
</div>
</template>
<script>
export default {
  data () {
    return {
      answerAudio: new Audio(),
      audioState: 'origin'
    }
  },
  methods: {
    togglePlay () {
      this.answerAudio.play()
      console.log(this.answerAudio.readyState)
    }
  },
  mounted () {
    this.answerAudio.src ='https://static.ladybirdedu.com/mp3/2018/05/04/v9DoVvZ1WPzepoO4cRELBAIRmgHz8CuOgG5UMaX4.m4a'
    let vm = this
    this.answerAudio.load()
    this.answerAudio.addEventListener('stalled', function (e) {
      vm.audioState = 'stalled'
      console.log('stalled')
    })
    this.answerAudio.addEventListener('error', function (e) {
      console.log('error')
      vm.audioState = 'error'
    })
    this.answerAudio.addEventListener('playing', function (e) {
      vm.audioState = 'playing'
      console.log('playing')
    })
    this.answerAudio.addEventListener('suspend', function (e) {
      vm.audioState = 'suspend'
      console.log('suspend')
    })
    this.answerAudio.addEventListener('canplay', function (e) {
      vm.audioState = 'canplay'
      console.log('canplay')
    })
    this.answerAudio.addEventListener('loadstart', function (e) {
      vm.audioState = 'loadstart'
      console.log('loadstart')
    })
  }
}
</script>

if i import fastclick in main.js, the audio load start event will not be be triggered,and it wont play any way.
Ios version is 12.2
The browser is safari

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions