Skip to content

Commit

Permalink
Update play/pause button
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Ory committed Mar 19, 2024
1 parent 6c37488 commit fcf222c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 50 deletions.
2 changes: 0 additions & 2 deletions work/scripts-listeners.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,8 @@
document.addEventListener("click", toggleAnalysisDisplay);

function toggleAnalysisDisplay(event) {
console.warn("TARGET", event.target);
let target = event.target;
if (!target.classList.contains("analysis-toggle")) {
console.warn("Not an analysis-toggle button");
return;
}
let analysisId = target.id;
Expand Down
86 changes: 38 additions & 48 deletions work/scripts-local.html
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@
id = DATA1520.workid;
}
let workinfo = DATA1520.lookup.works[id];
console.log("WORKINFO", workinfo);

let output = "";

Expand Down Expand Up @@ -384,65 +383,56 @@
AUDIO.style.zIndex = '1';

AUDIO.onpause = function () {
TurnOffAllNotes();
//TurnOffAllNotes();
}


let audiobutton;
console.warn(ID1520s, "ID1520s 1");
console.warn(AUDIO1520sid, "AUDIO1520sid 1");
console.warn(AUDIOid, "AUDIOid 1");
if (ID1520s != AUDIO1520sid) {
if (!!AUDIOid) {
// turn off previously playing audio file:
audiobutton = document.getElementById(audiobutton);
if (!!audiobutton && !!audiobutton.className) {
if (audiobutton.className.match(/mp3/)) {
audiobutton.className = 'mp3play';
} else {
audiobutton.className = 'play';
if (!!AUDIOid) {
// turn off previously playing audio file:
audiobutton = document.getElementById(AUDIOid);
if (!!audiobutton && !!audiobutton.className) {
if (audiobutton.className.match(/mp3/)) {
audiobutton.className = 'mp3play';
} else {
audiobutton.className = 'play';
}
}
}
}
AUDIO.removeAttribute('controls');
AUDIO.pause();

AUDIOid = ID1520s;
let source = '';
// Can't have seekable dynamic content in audio element:
//source += '<source src="/data?a=mp3&id=' + ID1520s + '" ';
source += '<source src="http://data.1520s-project.org/' + ID1520s + '.mp3" ';
source += 'type="audio/mpeg"/>\n';
AUDIO.innerHTML = source;

AUDIO1520sid = ID1520s;
AUDIO.load();
if (starttime) {
AUDIO.currentTime = starttime;
}
AUDIO.removeAttribute('controls');
AUDIO.pause();

AUDIOid = element.id;
let source = '';
// Can't have seekable dynamic content in audio element:
source += '<source src="http://data.1520s-project.org/' + ID1520s + '.mp3" ';
source += 'type="audio/mpeg"/>\n';
AUDIO.innerHTML = source;

AUDIO1520sid = ID1520s;
AUDIO.load();
if (starttime) {
AUDIO.currentTime = starttime;
}

console.warn(ID1520s, "ID1520s 2");
console.warn(AUDIO1520sid, "AUDIO1520sid 2");
console.warn(AUDIOid, "AUDIOid 2");
console.warn(source);
AUDIO.play();
//InitializeTimemap();

AUDIO.play();
//InitializeTimemap();
AUDIO.setAttribute('controls', 'controls');
let newelement = document.getElementById(AUDIOid);

AUDIO.setAttribute('controls', 'controls');
let newelement = document.getElementById(audiobutton);
AUDIO.addEventListener("ended", function() {
newelement.className = "play";
});

AUDIO.addEventListener("ended", function() {
newelement.className = "play";
});

if (newelement.className.match(/mp3/)) {
newelement.className = 'mp3pause';
} else {
newelement.className = 'pause';
}
if (newelement.className.match(/mp3/)) {
newelement.className = 'mp3pause';
} else {
newelement.className = 'pause';
}

return;
return;
}


Expand Down

0 comments on commit fcf222c

Please sign in to comment.