//videoLoad
function story_component_audioplayer_load() {
  for (key in dataStory) {
    var dataObject = dataStory[key];

    if (dataObject["objectType"] == "audioplayer") {
      //grp
      var object = new Konva.Group({
        id: key,
        x: dataObject["x"],
        y: dataObject["y"],
      });
      grpStory.add(object);
      object.setAttr("data", dataObject);

      //rect
      var rect = new Konva.Rect({
        x: 0,
        y: 0,
        width: dataObject["width"],
        height: dataObject["height"],
      });
      object.add(rect);

      object.on("pointerdown ", function () {
        story_component_audioplayer_click(this);
      });

      initButton(object, 0);
    }
  }
}

function story_component_audioplayer_click(e) {
  story_component_audioplayer_pauseall();
  var audio = document.getElementById("audio");
  audio.src = stagePath + e.getAttr("data")["image"];
  audio.play();
  document.getElementById("qcAudioBox").style.display = "block";
}

document.getElementById("qcAudioBox").style.display = "none";

document.getElementById("qcAudioBoxClose").onclick = function () {
  document.getElementById("audio").pause();
  document.getElementById("qcAudioBox").style.display = "none";
};

function story_component_audioplayer_pauseall() {
  for (key in dataStory) {
    let dataObject = dataStory[key];
    if (dataObject["objectType"] == "audio") {
      if (dataObject["image"]) {
        story_component_audio_player_internal[key].pause();
      }
    }
  }
}
