Merge pull request #834 from jaredb7/Spectrogram-Controls-Fix

Check RTSP stream selection control is valid
This commit is contained in:
ehpersonal38
2023-04-08 11:11:59 -04:00
committed by GitHub
+10 -8
View File
@@ -481,9 +481,10 @@ h1 {
<script> <script>
var rtsp_stream_select = document.getElementById("rtsp_stream_select"); var rtsp_stream_select = document.getElementById("rtsp_stream_select");
//When the dropdown selection is changed set the new value is settings, then restart the livestream service so it broadcasts newly selected RTSP stream if (typeof (rtsp_stream_select) !== 'undefined' && rtsp_stream_select !== null) {
rtsp_stream_select.onchange = function() { //When the dropdown selection is changed set the new value is settings, then restart the livestream service so it broadcasts newly selected RTSP stream
if (this.value !== 'undefined'){ rtsp_stream_select.onchange = function () {
if (this.value !== 'undefined') {
// Get the audio player element // Get the audio player element
var audio_player = document.querySelector('audio#player'); var audio_player = document.querySelector('audio#player');
var central_controls_element = document.getElementsByClassName('centered')[0]; var central_controls_element = document.getElementsByClassName('centered')[0];
@@ -491,22 +492,22 @@ rtsp_stream_select.onchange = function() {
//Create the loading header again as a placeholder while we're waiting to reload the stream //Create the loading header again as a placeholder while we're waiting to reload the stream
var h1_loading = document.createElement("H1"); var h1_loading = document.createElement("H1");
var h1_loading_text = document.createTextNode("Loading..."); var h1_loading_text = document.createTextNode("Loading...");
h1_loading.setAttribute("id","loading-h1"); h1_loading.setAttribute("id", "loading-h1");
h1_loading.setAttribute("style","font-size:48px; font-weight: bolder; color: #FFF"); h1_loading.setAttribute("style", "font-size:48px; font-weight: bolder; color: #FFF");
h1_loading.appendChild(h1_loading_text); h1_loading.appendChild(h1_loading_text);
// Create the XMLHttpRequest object. // Create the XMLHttpRequest object.
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
// Initialize the request // Initialize the request
xhr.open("GET", './views.php?rtsp_stream_to_livestream='+ this.value +'&view=Advanced&submit=advanced'); xhr.open("GET", './views.php?rtsp_stream_to_livestream=' + this.value + '&view=Advanced&submit=advanced');
// Send the request // Send the request
xhr.send(); xhr.send();
// Fired once the request completes successfully // Fired once the request completes successfully
xhr.onload = function(e) { xhr.onload = function (e) {
// Check if the request was a success // Check if the request was a success
if (this.readyState === XMLHttpRequest.DONE && this.status === 200) { if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
// Restart the audio player in case it stopped working while the livestream service was restarted // Restart the audio player in case it stopped working while the livestream service was restarted
if(audio_player !== 'undefined'){ if (audio_player !== 'undefined') {
central_controls_element.appendChild(h1_loading); central_controls_element.appendChild(h1_loading);
//Wait 5 seconds before restarting the stream //Wait 5 seconds before restarting the stream
setTimeout(function () { setTimeout(function () {
@@ -523,6 +524,7 @@ rtsp_stream_select.onchange = function() {
} }
} }
} }
}
} }
var slider = document.getElementById("gain_input"); var slider = document.getElementById("gain_input");