闫增涛
2024-06-05 3fb594dc317848107fd7bbb51631cfb763c19f5f
src/components/miniAudio/index.vue
@@ -1,6 +1,6 @@
<template>
  <div class="mini-audio" v-if="path">
    <audio controls :src="path"></audio>
    <audio controls :src="path" class="aduioPlayer"></audio>
  </div>
</template>
@@ -9,10 +9,48 @@
    name:"mini-audio",
    props:{
      path:{
        type:String
      type: String,
    },
    currentTime: {
      type: Number,
    },
  },
  watch: {
    path: {
      handler(newVal) {
        if (newVal) {
          setImmediate(() => {
            this.play();
          }, 200);
      }
      },
    },
  },
  methods: {
    play() {
      const player = (this.container ? this.container : document).querySelector(
        ".aduioPlayer"
      );
      if (player) {
        player.currentTime = this.currentTime;
        player.play();
    }
    },
    getVideoPlayer() {
      let obj = null;
      const player = (this.container ? this.container : document).querySelector(
        ".aduioPlayer"
      );
      if (player) {
        obj = {
          currentTime: player.currentTime,
          paused: player.paused,
        };
  }
      return obj
    },
  },
};
</script>
<style lang="less" scoped>