If you use the latest adaption to get the Hype scene details which @MaxZieb has put into extension form , you then only need one function.
You can load the Extension on the first scene. The Extension is added to the hypeDocuments scope.
From there we can query the current scene for its auto element by tag.
And we also just need to give each button and other elements a class name like play, pause, slider, rewind, Range.
Then we can get each scenes buttons and range values
We then use a switch to do the corresponding actions related to the button class name that was clicked.
This all means we do not need loads of functions and we use class names which is a normal rather giving multiple elements the same id and we do not need to mess about with scene names.
Extension code:
hypeDocument.getCurrentSceneIndex = function(){
var hc = document.getElementById(hypeDocument.documentId());
var sa = hc.getElementsByClassName("HYPE_scene");
for (i = 0; i < sa.length; i++) {
if ( sa[i].style.display === "block") return i;
}
}
hypeDocument.getCurrentSceneElement = function(){
var hc = document.getElementById(hypeDocument.documentId());
var sa = hc.getElementsByClassName("HYPE_scene");
for (i = 0; i < sa.length; i++) {
if ( sa[i].style.display === "block") return sa[i];
}
}
control function: ( all buttons run this )
var eleClass = element.classList[1];
var hypeESceneElement = hypeDocument.getCurrentSceneElement();
var myAudio = hypeESceneElement.querySelector('audio');
var mySpeed = hypeESceneElement.querySelector('.speed');
var myRange = hypeESceneElement.querySelector('.Range').value
switch(eleClass) {
case "play":
myAudio.play();
break;
case "pause":
myAudio.pause();
break;
case "slider" :
mySpeed.innerHTML = myRange;
myAudio.playbackRate = 0.01 * myRange;
break;
case "rewind" :
myAudio.currentTime = 0;
break;
}
draken gitaar nl_VMH 2.hype.zip (2.9 MB)