import _extends from "@babel/runtime/helpers/esm/extends";

/**
 * 波形图音频播放器
 * */
import { domId } from '../__support/util.js';
import './index-sfc.css';

var __vue_render__ = function __vue_render__() {
  var _vm = this;

  var _h = _vm.$createElement;

  var _c = _vm._self._c || _h;

  return _c('div', {
    attrs: {
      "id": _vm.domID
    }
  });
};

var __vue_staticRenderFns__ = [];
export default {
  render: __vue_render__,
  staticRenderFns: __vue_staticRenderFns__,
  name: "AudioPlayer",
  props: {
    options: {
      type: Object,
      default: function _default() {
        return {};
      }
    },
    seekAble: {
      type: Boolean,
      default: true
    },
    subscribeTimes: {
      type: Array,
      default: function _default() {
        /** item format:
         * {
         *   time: Number(s)
         * }
         * */
        return [];
      }
    }
  },
  emits: ['ready', 'ended', 'pause', 'play', 'timeUp'],
  data: function data() {
    return {
      domID: domId(),
      player: null,
      currentTime: 0
    };
  },
  computed: {
    timeListeners: function timeListeners() {
      var _this = this;

      return this.subscribeTimes.map(function (item) {
        return _extends({}, item, {
          pass: item.time < _this.currentTime
        });
      });
    },
    timeTarget: function timeTarget() {
      return this.timeListeners.filter(function (item) {
        return !item.pass;
      })[0];
    }
  },
  mounted: function mounted() {},
  beforeDestroy: function beforeDestroy() {
    if (this.player) {
      this.player.destroy();
    }
  }
};