mirror of https://bitbucket.org/ausocean/av.git
mjpeg-player: simplified main.js's load function
This commit is contained in:
parent
09c254e1f0
commit
fd5425659d
|
@ -42,10 +42,10 @@ init();
|
||||||
function load() {
|
function load() {
|
||||||
let url = document.getElementById('url').value;
|
let url = document.getElementById('url').value;
|
||||||
if (url == "") {
|
if (url == "") {
|
||||||
url = getQuery()
|
// Get everything following the ? from the browser's URL bar.
|
||||||
|
url = window.location.search.slice(1);
|
||||||
document.getElementById('url').value = url;
|
document.getElementById('url').value = url;
|
||||||
}
|
} else if (url[0] == '/') {
|
||||||
if (url[0] == '/') {
|
|
||||||
url = window.location.protocol + '//' + window.location.host + url;
|
url = window.location.protocol + '//' + window.location.host + url;
|
||||||
}
|
}
|
||||||
if (url == "") {
|
if (url == "") {
|
||||||
|
@ -56,17 +56,6 @@ function load() {
|
||||||
hls.loadSource(url, append);
|
hls.loadSource(url, append);
|
||||||
}
|
}
|
||||||
|
|
||||||
// getQuery gets everything after the question mark from the URL in the browser's URL bar.
|
|
||||||
function getQuery() {
|
|
||||||
let regex = new RegExp("\\?(.*)");
|
|
||||||
let match = regex.exec(window.location.href);
|
|
||||||
if (match == null) {
|
|
||||||
return '';
|
|
||||||
} else {
|
|
||||||
return decodeURIComponent(match[1].replace(/\+/g, " "));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// append, on the first call, starts a player worker and passes it a frame rate and the video data,
|
// append, on the first call, starts a player worker and passes it a frame rate and the video data,
|
||||||
// on subsequent calls it passes the video data to the player worker.
|
// on subsequent calls it passes the video data to the player worker.
|
||||||
function append(data) {
|
function append(data) {
|
||||||
|
|
Loading…
Reference in New Issue