AI销管
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

81 lines
1.7 KiB

  1. import {
  2. mapState,
  3. mapActions,
  4. mapMutations
  5. } from 'vuex'
  6. export const audios = {
  7. data() {
  8. return {}
  9. },
  10. computed: {
  11. ...mapState(['bgAudioMannager', 'isBgPlay']),
  12. },
  13. methods: {
  14. setAudio(obj) {
  15. this.bgAudioMannager.title = '录音音频';
  16. this.bgAudioMannager.src = obj.src
  17. this.bgAudioMannager.startTime = obj.currentTime
  18. },
  19. setAudioFunc() {
  20. this.bgAudioMannager.onCanplay(() => {
  21. console.log('可以播放');
  22. });
  23. this.bgAudioMannager.onStop(() => {
  24. console.log('停止播放');
  25. });
  26. this.bgAudioMannager.onPause(() => {
  27. console.log('暂停播放');
  28. // 设置当前暂停的视频播放位置
  29. // this.seek(this.bgAudioMannager.currentTime)
  30. // this.play()
  31. });
  32. this.bgAudioMannager.onEnded(() => {
  33. console.log('自然播放结束事件');
  34. });
  35. this.bgAudioMannager.onError((res) => {
  36. console.log(res.errMsg);
  37. console.log(res.errCode);
  38. });
  39. this.bgAudioMannager.onTimeUpdate(() => {
  40. this.duration = this.bgAudioMannager.duration;
  41. this.currentTime = this.bgAudioMannager.currentTime;
  42. this.$emit('timeUpdate', {
  43. duration: this.bgAudioMannager.duration,
  44. currentTime: this.bgAudioMannager.currentTime
  45. })
  46. });
  47. },
  48. // 背景音频暂停
  49. audioPause() {
  50. this.bgAudioMannager.pause()
  51. },
  52. // 背景音频播放
  53. audioPlay() {
  54. this.pause()
  55. this.bgAudioMannager.play()
  56. },
  57. //背景音频指定秒数播放
  58. audioSeek(t) {
  59. this.bgAudioMannager.seek(t)
  60. },
  61. // 停止背景音频播放
  62. stopAduio() {
  63. if (this.bgAudioMannager != null) {
  64. this.bgAudioMannager.pause()
  65. if (this.bgAudioMannager.src != '') {
  66. this.bgAudioMannager.src = ''
  67. }
  68. }
  69. }
  70. }
  71. }