Streaming live at 10am (PST)

Javascript does not work

Hello! Can anyone tell me why this script isn’t working?
______ 1 ______ is a field from CMS, which outputs yes/no.
______ 2 ______ is a field from CMS, which outputs the URL to the source file.

I have also tried running the script without CMS by putting the values directly in the script. Didn’t work either.

<div id="anchorbox"></div>

<script>
function videoORaudio(){
    let v="______1______";
		
	let source = document.createElement('source');
	
	let audio = document.createElement("audio");
	audio.id="videoORaudio";
	
	let video = document.createElement("video");
	video.id="videoORaudio";
	video.style.width = "480";
	video.style.height = "270";
	
	if (v === "no"){
	insertAfter(document.getElementById("anchorbox"), (audio));
	audio.appendChild(source);
  source.setAttribute('src', '______ 2 ______');
	source.type="audio/mpeg";
	}else{
	insertAfter(document.getElementById("anchorbox"), (video));	
	video.appendChild(source);
  source.setAttribute('src', ' ______ 2 ______');
	source.type="video/mp4";
	}
	document.getElementById("videoORaudio").controls = true; 
function insertAfter(referenceNode, newNode) {
    referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}
</script>

Thanks for the help!

I actually do not see your function invokation. At this time function videoORaudio is created but it sitting there waiting to be invoked. I do not know your code but you should create a event listener that will run your function as function itself do nothing it is just a few lines of code waiting to be used.