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

关于监听播放器状态 #68

Closed
667-1 opened this issue Jun 8, 2018 · 3 comments
Closed

关于监听播放器状态 #68

667-1 opened this issue Jun 8, 2018 · 3 comments
Labels

Comments

@667-1
Copy link

667-1 commented Jun 8, 2018

大佬我想监听播放器播放状态试过几种办法我能 想到的但是无果 在探索过程中发现下面问题:
1、我在 vuex中设置了一个参数isPlaying 默认false 目的是用来判断是否播放 并且在获取数据之后改变这个值true
2、我在update 生命周期中判断 这个值 假如是真的话就调用 this.$refs.player.play();
3、然后我打印this.$refs.player.isPlaying 显示是false (并且会打印两次), aplayer的播放状态参数 isPlaying 并没有立即改变过来
4、除过第一首之后打印的值都是true ,使用 this.$nextTick 结果也一样

因为我想做一个歌曲展开面板 里面的按钮可以控制播放或者暂停 现在我不知道该怎么搞了
求大佬给个思路 能监听播放器播放状态

@SevenOutman
Copy link
Owner

@OneKissAndOneShot player.toggle() 可以控制播放器播放/暂停,player.isPlaying 是播放器当前的状态。你可以不用自己去判断该调 play() 还是 pause(),直接通过 isPlaying 来显示不同的按钮,点击的时候调 toggle() 就可以了。

如果不太明白的话,不妨贴一些你的代码?

@667-1
Copy link
Author

667-1 commented Jun 8, 2018

我先试试看

@SevenOutman
Copy link
Owner

@OneKissAndOneShot 使用方面的问题你可以加入 Discord 来讨论

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

No branches or pull requests

2 participants