Commit 693b2353 authored by Mario Botsch's avatar Mario Botsch
Browse files

add jingle plugin

parent be5cdd65
......@@ -7,11 +7,14 @@ let RevealJingle = (function () {
let jingles = [];
function createJingle(filename, style) {
function createJingle(filename, style, volume) {
console.log(" add jingle " + filename + " with volume " + (volume?volume:"1.0"));
const defaultStyle = "display:block; position:absolute; left:0; right:0; top:0; bottom:0; margin:auto; object-fit:contain; pointer-events:none;"
let vid = document.createElement("video");
vid.style = style ? defaultStyle+style : defaultStyle;
if (volume) vid.volume = volume;
vid.src = filename;
vid.onplay = () => { jingleLayout.style.display = "flex"; vid.style.display = "block"; }
vid.onended = () => { jingleLayout.style.display = vid.style.display = "none"; }
......@@ -24,12 +27,12 @@ let RevealJingle = (function () {
// setup container
const reveal = document.querySelector(".reveal");
jingleLayout = document.createElement("div");
jingleLayout.style = "display:flex; flex-flow: column nowrap; justify-content:center; position:fixed; left:0; right:0; top:0; bottom:0; margin:0; z-index:100; background:none;";
jingleLayout.style = "display:none; flex-flow: column nowrap; justify-content:center; position:fixed; left:0; right:0; top:0; bottom:0; margin:0; z-index:40; background:none; pointer-events:none;";
reveal.appendChild(jingleLayout);
// setup video element per jingle
for (let i=0; i<config.length; i++) {
jingles.push( createJingle(config[i].vid, config[i].css) );
jingles.push( createJingle(config[i].vid, config[i].css, config[i].vol) );
}
}
......@@ -44,7 +47,7 @@ let RevealJingle = (function () {
{
keyCode: 49 + i,
key: String.fromCharCode(49 + i),
description: "Play jingle " + i,
description: "Play jingle " + (i+1),
},
() => {
playJingle(i);
......@@ -55,7 +58,7 @@ let RevealJingle = (function () {
return {
init: function () {
console.log("init jingle plugin");
console.log("initialize jingles plugin");
if (config.length) {
setupJingles();
setupKeyBindings();
......
......@@ -637,7 +637,12 @@ $if(quizServer)$
// Mario's multiple-choice quiz
quiz: { server: "$quizServer$" },
$endif$
$if(jingles)$
// Mario's video jingles
jingles: Decker.meta.jingles,
$endif$
// plugins
dependencies: [
{ src: String.raw`$decker-support-dir$/plugins/charts/Chart.js`},
......@@ -658,6 +663,7 @@ $if(highlightjs)$
$endif$
$if(mario)$
{ src: String.raw`$decker-support-dir$/plugins/quiz/quiz.js` },
{ src: String.raw`$decker-support-dir$/plugins/jingles/jingles.js`, async: true },
$endif$
$if(menu)$
{ src: String.raw`$decker-support-dir$/plugins/menu/menu.js`, async: true },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment