chromecast for no https and on non loopback server

This commit is contained in:
jr-k 2024-08-20 19:36:17 +02:00
parent 812a9ab0f4
commit 616bab254a

View File

@ -54,10 +54,18 @@
var script_sender = document.createElement('script'); var script_sender = document.createElement('script');
script_sender.src = "{{ STATIC_PREFIX }}js/lib/cast-sender.js"; script_sender.src = "{{ STATIC_PREFIX }}js/lib/cast-sender.js";
document.body.appendChild(script_sender); document.body.appendChild(script_sender);
const isHttps = document.location.protocol.indexOf('https') === 0;
const isLoopback = document.location.host.indexOf('localhost') === 0 || document.location.host.indexOf('127.0.0.1') === 0;
var script_caster = document.createElement('script'); if (isLoopback || !isHttps) {
script_caster.src = "{{ STATIC_PREFIX }}js/cast-url.js"; var script_caster = document.createElement('script');
document.body.appendChild(script_caster); script_caster.src = "{{ STATIC_PREFIX }}js/cast-url.js";
document.body.appendChild(script_caster);
} else {
$(document).on('click', '.cast-url', function() {
window.open('https://cast.obscreen.io/sender.html?url=' + encodeURIComponent($('#' + $(this).attr('data-target-id')).val()));
});
}
} }
}); });
</script> </script>