Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The demo doesn't work on Safari for Mac. #373

Open
shaoyaoqian opened this issue Dec 6, 2022 · 2 comments
Open

The demo doesn't work on Safari for Mac. #373

shaoyaoqian opened this issue Dec 6, 2022 · 2 comments

Comments

@shaoyaoqian
Copy link

No description provided.

@shaoyaoqian shaoyaoqian changed the title It doesn't work on Safari for Mac. The demo doesn't work on Safari for Mac. Dec 6, 2022
@shaoyaoqian
Copy link
Author

可能的原因:在Safari上,点击播放按钮后,音频不会自动加载。在play之前需要load函数。

@shaoyaoqian
Copy link
Author

在safari中,如果audio的preload属性是metadata,或者none,那么始终不会出发canplay事件。因此需要在play函数中加入下面这一段代码:

      if (!this.canPlay) {
        this.audio.load()
      }

点击播放按钮后,如果这首歌不能播放,那么会先试着加载一下,加载会触发canplay事件了,然后把canPlay设为true,后面的逻辑就通顺了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant