#include "Sound.hpp"
#ifdef _MSC_VER
#include <windows.h>
#else
#include <string>
#endif

void Sound::play(const char* name) {
#ifdef _MSC_VER
  PlaySound(
    name,
    name ? GetModuleHandle(NULL) : NULL,
    name ? SND_RESOURCE | SND_ASYNC : 0
  );
#else
  static int error = 0;
  if (!error) {
    error = std::system(
      (
        (
          std::string("cvlc --no-repeat --no-loop --play-and-exit --no-interact --no-stats --daemon sound/wav/") += name
        ) += ".wav 2> /dev/null"
      ).c_str()
    );
  }
#endif
}

void Sound::alarm() {
  play("alarm");
}

void Sound::bang() {
  play("bang");
}

void Sound::fire() {
  play("fire");
}

void Sound::life() {
  play("life");
}
