"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _reactNative = require("react-native");
const {
  RNSoundPlayerChatVT
} = _reactNative.NativeModules;
const RNSoundPlayer = RNSoundPlayerChatVT;
const _soundPlayerEmitter = new _reactNative.NativeEventEmitter(RNSoundPlayer);
let _finishedPlayingListener = null;
let _finishedLoadingListener = null;
var _default = {
  playSoundFile: (name, type) => {
    RNSoundPlayer.playSoundFile(name, type);
  },
  playSoundFileWithDelay: (name, type, delay) => {
    RNSoundPlayer.playSoundFileWithDelay(name, type, delay);
  },
  loadSoundFile: (name, type) => {
    RNSoundPlayer.loadSoundFile(name, type);
  },
  setNumberOfLoops: loops => {
    RNSoundPlayer.setNumberOfLoops(loops);
  },
  playUrl: url => {
    RNSoundPlayer.playUrl(url);
  },
  loadUrl: url => {
    RNSoundPlayer.loadUrl(url);
  },
  onFinishedPlaying: callback => {
    if (_finishedPlayingListener) {
      _finishedPlayingListener.remove();
      _finishedPlayingListener = undefined;
    }
    _finishedPlayingListener = _soundPlayerEmitter.addListener("FinishedPlaying", callback);
  },
  onFinishedLoading: callback => {
    if (_finishedLoadingListener) {
      _finishedLoadingListener.remove();
      _finishedLoadingListener = undefined;
    }
    _finishedLoadingListener = _soundPlayerEmitter.addListener("FinishedLoading", callback);
  },
  addEventListener: (eventName, callback) => _soundPlayerEmitter.addListener(eventName, callback),
  play: () => {
    // play and resume has the exact same implementation natively
    RNSoundPlayer.resume();
  },
  pause: () => {
    RNSoundPlayer.pause();
  },
  resume: () => {
    RNSoundPlayer.resume();
  },
  stop: () => {
    RNSoundPlayer.stop();
  },
  seek: seconds => {
    RNSoundPlayer.seek(seconds);
  },
  setVolume: volume => {
    RNSoundPlayer.setVolume(volume);
  },
  setSpeaker: on => {
    RNSoundPlayer.setSpeaker(on);
  },
  setMixAudio: on => {
    if (_reactNative.Platform.OS === "android") {} else {
      RNSoundPlayer.setMixAudio(on);
    }
  },
  getInfo: async () => RNSoundPlayer.getInfo(),
  unmount: () => {
    if (_finishedPlayingListener) {
      _finishedPlayingListener.remove();
      _finishedPlayingListener = undefined;
    }
    if (_finishedLoadingListener) {
      _finishedLoadingListener.remove();
      _finishedLoadingListener = undefined;
    }
  }
};
exports.default = _default;
//# sourceMappingURL=index.js.map