{"id":2290,"date":"2022-09-06T16:14:42","date_gmt":"2022-09-06T14:14:42","guid":{"rendered":"https:\/\/www.fm1.be\/?page_id=2290"},"modified":"2022-09-22T09:22:29","modified_gmt":"2022-09-22T07:22:29","slug":"youtube-mixer","status":"publish","type":"page","link":"https:\/\/www.fm1.be\/index.php\/youtube-mixer\/","title":{"rendered":"Youtube Mixer"},"content":{"rendered":"\n<br>\n<div>\n<div>\n\n\t\n                 <select id=\"audioOutput1\" style=\"width: 35%; float:left; height:50px; margin: 0px; box-shadow:inset 0px 0px 0px 2px black;background:#303d49 \">\n\t\t\t<option value=\"1\">\n\t\t\t\t\t1\n\t\t\t\t<\/option>\n\t<\/select>\t\n\n\n\n                 <select id=\"audioOutput2\" style=\"width: 35%; float:RIGHT; height:50px; margin: 0px; box-shadow:inset 0px 0px 0px 2px black;background:#303d49 \">\n                                <option value=\"1\">\n\t\t\t\t\t1\n\t\t\t\t<\/option>\n<\/select>\n<\/div>\n<br>\n<br>\n<br>\n\n\n\n\n<iframe id=\"iframe\" name=\"iframe\" class=\"iframe\" src=\"https:\/\/www.fm1.be\/ytm.html\" allow=\"camera *;microphone *\" title=\"fm1 youtube mixer\" scrolling=\"no\" style=\" width: 100%; height: 700px;  overflow: hidden;\" frameborder=\"0\"><\/iframe>\n\n\n<script>\nvar iframe_window = window.frames[\"iframe\"];\n\niframe_window .focus();\n\n\njQuery(document).ready(function () {\n    jQuery('iframe').load(function() {\n        iframe_window .focus()\n    });\n})\n\ndocument.addEventListener('keydown', function(event){\n\tif(event.key === \"Escape\"){\n\t\tiframe_window .focus();\n\t}\n});\n\n\n\nconst audioOutputSelect1 = document.querySelector('select#audioOutput1');\nconst audioOutputSelect2 = document.querySelector('select#audioOutput2');\n\n\nconst selector1 = [audioOutputSelect1];\nconst selector2 = [audioOutputSelect2];\n\n\nvar op1 = \"default\";\nvar op2 = \"default\";\naudioOutputSelect1.disabled = !('sinkId' in HTMLMediaElement.prototype);\naudioOutputSelect2.disabled = !('sinkId' in HTMLMediaElement.prototype);\n\nvar xmlHttpr = new XMLHttpRequest();\nxmlHttpr.open(\"GET\", \"https:\/\/fm1.be\/writel.php?input=0\",true);\nxmlHttpr.open(\"GET\", \"https:\/\/fm1.be\/writer.php?input=0\",true);\nxmlHttpr.send();\n\n\n\n\nnavigator.mediaDevices.getUserMedia({ audio: true })\n      .then(function(stream) {\n        console.log('You let me use your mic!')\n      })\n      .catch(function(err) {\n        console.log('No mic for you!')\n      });\n\nfunction gotDevices(deviceInfos) {\n    \/\/ Handles being called several times to update labels. Preserve values.\n    const value1 = selector1.map(select => select.value);\n    selector1.forEach(select => {\n        while (select.firstChild) {\n            select.removeChild(select.firstChild);\n        }\n    });\n\n    for (let i = 0; i !== deviceInfos.length; ++i) {\n        const deviceInfo = deviceInfos[i];\n        const option1 = document.createElement('option');\n        option1.value = deviceInfo.deviceId;\n        if (deviceInfo.kind === 'audiooutput') {\n            option1.text = deviceInfo.label || `speaker ${audioOutputSelect1.length + 1}`;\n            audioOutputSelect1.appendChild(option1);\n             \n        }  else {\n            console.log('Some other kind of source\/device: ', deviceInfo);\n        }\n    }\n    selector1.forEach((select, selectorIndex) => {\n        if (Array.prototype.slice.call(select.childNodes)\n            .some(n => n.value === value1[selectorIndex])) {\n            select.value = value1[selectorIndex];\n        }\n    });\n\nconst value2 = selector2.map(select => select.value);\n    selector2.forEach(select => {\n        while (select.firstChild) {\n            select.removeChild(select.firstChild);\n        }\n    });\n\n    for (let i = 0; i !== deviceInfos.length; ++i) {\n        const deviceInfo = deviceInfos[i];\n        const option2 = document.createElement('option');\n        option2.value = deviceInfo.deviceId;\n        if (deviceInfo.kind === 'audiooutput') {\n            option2.text = deviceInfo.label || `speaker ${audioOutputSelect2.length + 1}`;\n            audioOutputSelect2.appendChild(option2);\n             \n        }  else {\n            console.log('Some other kind of source\/device: ', deviceInfo);\n        }\n    }\n    selector1.forEach((select, selectorIndex) => {\n        if (Array.prototype.slice.call(select.childNodes)\n            .some(n => n.value === value2[selectorIndex])) {\n            select.value = value1[selectorIndex];\n        }\n    });\n\n\n\n}\n\naudioOutputSelect1.onchange = change1;\n\naudioOutputSelect2.onchange = change2;\n\nfunction change1() {\n\n\nvar xmlHttp1 = new XMLHttpRequest();\nxmlHttp1.open(\"GET\", \"https:\/\/fm1.be\/writel.php?input=\" + audioOutputSelect1.selectedIndex,true);\nxmlHttp1.send();\nsetTimeout(() => {  document.getElementById('iframe').contentWindow.location.reload(); }, 2000);\niframe_window .focus();\n\n}\n\nfunction change2() {\n\n\n\nvar xmlHttp2 = new XMLHttpRequest();\nxmlHttp2.open(\"GET\", \"https:\/\/fm1.be\/writer.php?input=\" + audioOutputSelect2.selectedIndex,true);\nxmlHttp2.send();\n\nsetTimeout(() => {  document.getElementById('iframe').contentWindow.location.reload(); }, 2000);\niframe_window .focus();\n}\n\n\n\nlet audioDevicesh = [];\nnavigator.mediaDevices.enumerateDevices()\n.then((devices) => {\n  audioDevicesh = devices.filter(device => device.kind === 'audiooutput');\n  \n  console.log(\"Found in head \" + audioDevicesh.length + \" output devices\");\n\n\nfor (let i = 0; i < audioDevicesh.length ; i++) {\n  console.log(\"device \"+i+ \" => \" + audioDevicesh[i].label);\n} \n  console.log(\" players  => \" + audioDevicesh[0].label);\n});\n\nnavigator.mediaDevices.enumerateDevices()\n    .then(gotDevices, console.log('xxxxxxxxx test'));\n    \/\/.catch(handleError);\n\nfunction handleError(error) {\n    console.log('navigator.MediaDevices.getUserMedia error: ', error.message, error.name);\n}\n<\/script><\/div>\n","protected":false},"excerpt":{"rendered":"<p>1 1<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"template-page-builders.php","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"class_list":["post-2290","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.fm1.be\/index.php\/wp-json\/wp\/v2\/pages\/2290","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.fm1.be\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.fm1.be\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.fm1.be\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fm1.be\/index.php\/wp-json\/wp\/v2\/comments?post=2290"}],"version-history":[{"count":153,"href":"https:\/\/www.fm1.be\/index.php\/wp-json\/wp\/v2\/pages\/2290\/revisions"}],"predecessor-version":[{"id":2512,"href":"https:\/\/www.fm1.be\/index.php\/wp-json\/wp\/v2\/pages\/2290\/revisions\/2512"}],"wp:attachment":[{"href":"https:\/\/www.fm1.be\/index.php\/wp-json\/wp\/v2\/media?parent=2290"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}