录音调听

<template>
  <div v-show="isShow" class="video-dialog" v-drag="drag">
    <audio :src="audioFile" controls="controls" ref="audio" class="audio"></audio>
    <div class="btn">
      <div class="close-area" @click="close">
        <i class="el-icon-close"></i>
      </div>
      <div class="drag-area" @mousedown="enableDrag" @mouseleave="disableDrag">
        <i class="el-icon-rank"></i>
      </div>
    </div>
  </div>
</template>

<script>
import {mapState} from 'vuex'
export default {
  name: 'VideoCall',
  data () {
    return {
      drag: false,
      isShow: false,
      audioFile: ''
    }
  },
  computed: {
    ...mapState(['isAudio'])
  },
  watch: {
    isAudio: {
      handler (val) {
        if (val) {
          this.showDialog(val)
        } else {
          this.audioFile = ''
        }
      },
      deep: true
    }
  },
  methods: {
    async showDialog (val) {
      const v = await this.getVideoData(val)
      if (v === true) {
        this.isShow = true
      } else {
        this.audioFile = ''
      }
    },
    getVideoData (val) {
      return new Promise((resolve, reject) => {
        this.axios({
          method: 'get',
          responseType: 'blob',
          url: val
        }).then((res) => {
          this.audioFile = window.URL.createObjectURL(res.data)
          resolve(true)
        })
      })
    },
    close () {
      this.isShow = false
      this.audioFile = ''
    },
    enableDrag () {
      this.drag = true
    },
    disableDrag () {
      this.drag = false
    }
  }
}
</script>

<style lang="scss" scoped>
.video-dialog {
  position: fixed;
  width: 400px;
  height: 50px;
  border-radius: 30px;
  box-shadow: 0px 3px 5px 0px #adadad;
  z-index: 2000;
  background-color: #f0f2f3;
  top: 78px;
  right: 20px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  .audio{
    width: 300px;
    height: 54px;
  }
  // .audio::-webkit-media-controls-panel {
  //   width: calc(100% + 100px);
  // }
  .btn{
    width: 40px;
    border-left: 1px dotted #1764ce;
    font-size: 20px;
    color: #1764ce;
    line-height: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding-left: 5px;
    .close-area{
      cursor: pointer;
    }
    .drag-area {
      cursor: move;
    }
  }
}
</style>

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容