Clean up HLS stream

Without this, it will continue loading chunks in the background.
This commit is contained in:
Chandler Swift 2024-02-02 21:46:21 -06:00
parent 572a8c6d3c
commit acad9c5944
Signed by: chandlerswift
GPG key ID: A851D929D52FB93F
2 changed files with 10 additions and 6 deletions

View file

@ -62,6 +62,7 @@ for (let [state, url] of Object.entries(allStates)) {
var hls = new Hls(); var hls = new Hls();
hls.loadSource(view.src); hls.loadSource(view.src);
hls.attachMedia(video); hls.attachMedia(video);
vectorLayer.destroyPopupCallback = () => hls.destroy();
} }
// iDevice support, untested (only works in Safari; required for iPhones) // iDevice support, untested (only works in Safari; required for iPhones)
else if (video.canPlayType('application/vnd.apple.mpegurl')) { else if (video.canPlayType('application/vnd.apple.mpegurl')) {

15
main.js
View file

@ -23,12 +23,6 @@ const popupOverlay = new Overlay({
}, },
}); });
closer.onclick = function () {
popupOverlay.setPosition(undefined);
closer.blur();
return false;
};
const contextMenu = new ContextMenu({ const contextMenu = new ContextMenu({
width: 170, width: 170,
defaultItems: false, defaultItems: false,
@ -147,6 +141,15 @@ map.on('click', function (evt) {
} }
popupOverlay.setPosition(evt.coordinate); popupOverlay.setPosition(evt.coordinate);
closer.onclick = function (){
popupOverlay.setPosition(undefined);
if (layer.hasOwnProperty('destroyPopupCallback')) {
layer.destroyPopupCallback(feature);
}
closer.blur();
return false;
};
}); });
new ResizeObserver(() => map.updateSize()).observe(document.getElementById("map")); new ResizeObserver(() => map.updateSize()).observe(document.getElementById("map"));