\n";
lines += string_f("
\n",width,height);
#if 0
lines += string_f("\n";
#endif
lines += "
\n";
lines += "
\n";
#if 0
script += string_f("const videoTag = document.getElementById('vidc-%s');\n",gameid.c_str());
script +=
"const myMediaSource = new MediaSource();\n"
"const url = URL.createObjectURL(myMediaSource);\n"
"myMediaSource.addEventListener('sourceopen', sourceOpen);\n"
"videoTag.src = url;\n"
"function sourceOpen(){\n"
//"\tvideoTag.play();\n"
"\tconsole.log('sourceopen state='+this.readyState); // open\n"
"\tconst mtype = 'video/mp4; codecs=\"avc1.64001e, mp4a.40.2,avc1.4d401e\"';\n"
"\tif (MediaSource.isTypeSupported(mtype)){\n"
"\t\tconsole.log('mp4 codec supported');\n"
"\t}else{\n"
"\t\tconsole.log('mp4 codec not supported');\n"
"\t}\n"
"\tsourcebuffer = this.addSourceBuffer(mtype);\n"
"\tconst curMode = sourcebuffer.mode;\n"
"\tif (curMode === 'segments') {\n"
"\t\tsourcebuffer.mode = 'sequence';\n"
"\t}\n"
"\tconsole.log ('sourcebuffer.mode='+sourcebuffer.mode);\n"
"\tsourcebuffer.addEventListener('update', function() {\n"
"\t\tconsole.log ('update');\n"
"\t\tif(vidc_chunks.length > 0){\n"
"\t\t\tsourcebuffer.appendBuffer(vidc_chunks.shift());\n"
"\t\t}\n"
"\t\t});\n"
"\tsourcebuffer.addEventListener('updateend', function() {\n"
"\t\tconsole.log ('updateend');\n"
"\t});\n"
"\tsourcebuffer.addEventListener('error', function(e) {\n"
"\t\tconsole.log ('buffer error');\n"
"\t\tconsole.log(e);\n"
"\t});\n"
"\tvideoTag.addEventListener('play', function() {\n"
"\t\tconsole.log ('play');\n"
"\t}, false);\n"
"\tvideoTag.addEventListener('playing', function() {\n"
"\t\tconsole.log ('playing');\n"
"\t}, false);\n"
"\tvideoTag.addEventListener('waiting', function() {\n"
"\t\tconsole.log ('waiting');\n"
"\t}, false);\n"
"\tvideoTag.addEventListener('stalled', function() {\n"
"\t\tconsole.log ('stalled');\n"
"\t}, false);\n"
"\tvideoTag.addEventListener('progress', function() {\n"
"\t\tconsole.log ('progress');\n"
"\t}, false);\n"
"\tvideoTag.addEventListener('timeupdate', function() {\n"
"\t\tconsole.log ('timeupdate');\n"
"\t}, false);\n"
"\tvideoTag.addEventListener('seeking', function() {\n"
"\t\tconsole.log ('seeking');\n"
"\t}, false);\n"
"\tvideoTag.addEventListener('seeked', function() {\n"
"\t\tconsole.log ('seeked');\n"
"\t}, false);\n"
"\tvideoTag.addEventListener('loadeddata', function() {\n"
"\t\tconsole.log ('loadeddata');\n"
"\t}, false);\n"
"\tvideoTag.addEventListener('loadedmetadata', function() {\n"
"\t\tconsole.log ('loadedmetadata');\n"
"\t}, false);\n"
"\tvideoTag.addEventListener('error', function(e) {\n"
"\t\tconsole.log ('videotag error');\n"
"\t\tconsole.log (e);\n"
"\t}, false);\n"
"}\n"
;
#endif
return lines;
}
/*
Generate the JS code to update the background of a button based on the state of a JS variable
*/
static void vidconf_update_button (string &script, const char *variable, unsigned button_id)
{
script += string_f("document.getElementById('button%u').style.background=%s ? 'lightblue' : 'lightgray';\n"
,button_id,variable);
}