|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- import {
- mapState,
- mapActions,
- mapMutations
- } from 'vuex'
- export const audios = {
- data() {
- return {
- isBgPlay: false, // 是否禁止拖拽进度条
- }
- },
-
- computed: {
- ...mapState(['bgAudioMannager']),
- },
-
- methods: {
- setAudio(obj) {
- this.bgAudioMannager.title = '录音音频';
- this.bgAudioMannager.src = obj.src
- this.bgAudioMannager.startTime = obj.currentTime
- },
-
- setAudioFunc() {
- this.bgAudioMannager.onCanplay(() => {
- console.log('可以播放');
- });
- this.bgAudioMannager.onStop(() => {
- console.log('停止播放');
- this.isBgPlay = false
- });
-
- this.bgAudioMannager.onPause(() => {
- console.log('暂停播放');
- this.isBgPlay = false
- // 设置当前暂停的视频播放位置
- // this.seek(this.bgAudioMannager.currentTime)
- // this.play()
- });
-
- this.bgAudioMannager.onEnded(() => {
- console.log('自然播放结束事件');
- this.isBgPlay = false
- });
-
- this.bgAudioMannager.onError((res) => {
- console.log(res.errMsg);
- console.log(res.errCode);
- });
-
- this.bgAudioMannager.onTimeUpdate(() => {
- this.isBgPlay = true
- this.duration = this.bgAudioMannager.duration;
- this.currentTime = this.bgAudioMannager.currentTime;
- this.$emit('timeUpdate', {
- duration: this.bgAudioMannager.duration,
- currentTime: this.bgAudioMannager.currentTime
- })
- });
- },
-
- // 背景音频暂停
- audioPause() {
- this.bgAudioMannager.pause()
- },
-
- // 背景音频播放
- audioPlay() {
- this.pause()
- this.bgAudioMannager.play()
- },
-
- //背景音频指定秒数播放
- audioSeek(t) {
- this.bgAudioMannager.seek(t)
- },
-
- // 停止背景音频播放
- stopAduio() {
- console.log(this.bgAudioMannager)
- this.bgAudioMannager.pause()
- if (this.bgAudioMannager && this.bgAudioMannager.src) {
- this.bgAudioMannager.src = ''
- }
- }
- }
- }
|