"use strict";
const common_vendor = require("../../../../common/vendor.js");
const _sfc_main = {
  props: {
    message: {
      type: Object,
      default: () => ({})
    },
    senderId: {
      type: String,
      default: ""
    },
    userId: {
      type: Number
    },
    playbackStatus: {
      type: Boolean
    }
  },
  data() {
    return {
      innerAudioContext: null,
      NumberClicks: 0
    };
  },
  watch: {
    playbackStatus(newVal) {
      if (!newVal) {
        if (this.innerAudioContext) {
          this.innerAudioContext.pause();
          this.innerAudioContext.destroy();
          this.innerAudioContext = null;
          this.NumberClicks = 0;
          this.$emit("notplayVoice", true);
        } else {
          this.$emit("notplayVoice", true);
        }
      } else {
        this.$emit("notplayVoice", true);
      }
    }
  },
  methods: {
    floor(num) {
      return Math.floor(num);
    },
    Play() {
      this.$emit("notplayVoice", false);
      setTimeout(() => {
        this.innerAudioContext = common_vendor.index.createInnerAudioContext();
        this.innerAudioContext.src = this.message.url;
        this.innerAudioContext.onEnded(() => {
          this.NumberClicks = 0;
          this.innerAudioContext.destroy();
          this.innerAudioContext = null;
        });
        this.innerAudioContext.onError((res) => {
          this.NumberClicks = 0;
          this.innerAudioContext.destroy();
          this.innerAudioContext = null;
        });
        this.innerAudioContext.play();
        this.NumberClicks = 1;
      }, 500);
    }
  }
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return common_vendor.e({
    a: $props.senderId == $props.userId
  }, $props.senderId == $props.userId ? common_vendor.e({
    b: common_vendor.t($options.floor($props.message.duration)),
    c: $data.NumberClicks == 0
  }, $data.NumberClicks == 0 ? {} : {}, {
    d: $data.NumberClicks == 1
  }, $data.NumberClicks == 1 ? {} : {}, {
    e: $data.NumberClicks == 2
  }, $data.NumberClicks == 2 ? {} : {}) : common_vendor.e({
    f: $data.NumberClicks == 0
  }, $data.NumberClicks == 0 ? {} : {}, {
    g: $data.NumberClicks == 1
  }, $data.NumberClicks == 1 ? {} : {}, {
    h: $data.NumberClicks == 2
  }, $data.NumberClicks == 2 ? {} : {}, {
    i: common_vendor.t($options.floor($props.message.duration))
  }), {
    j: common_vendor.o((...args) => $options.Play && $options.Play(...args))
  });
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-2ecc0080"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/pages/index/chat/messageComponent/voiceMessage.js.map
