fix: play segments
This commit is contained in:
@@ -129,11 +129,11 @@ const loadMedia = (hash) => {
|
||||
|
||||
const play = (hash, type) => {
|
||||
const player = document.getElementById("video");
|
||||
const source = `/v1/medias/${hash}/${type}`;
|
||||
const source = `/v1/medias/${hash}/${type}?token=${__GA}`;
|
||||
if (Hls.isSupported()) {
|
||||
var hls = new Hls({
|
||||
xhrSetup: function (xhr, url) {
|
||||
xhr.setRequestHeader("Authorization", "Bearer " + __GA);
|
||||
xhr.withCredentials = true;
|
||||
},
|
||||
});
|
||||
hls.loadSource(source);
|
||||
@@ -142,19 +142,10 @@ const play = (hash, type) => {
|
||||
player.play();
|
||||
});
|
||||
} else if (player.canPlayType("application/vnd.apple.mpegurl")) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', source, true);
|
||||
xhr.setRequestHeader("Authorization", "Bearer " + __GA);
|
||||
xhr.responseType = 'blob';
|
||||
xhr.onload = function () {
|
||||
if (xhr.status === 200) {
|
||||
player.src = URL.createObjectURL(xhr.response);
|
||||
player.addEventListener("loadedmetadata", function () {
|
||||
player.play();
|
||||
});
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
player.src = source;
|
||||
player.addEventListener("loadedmetadata", function () {
|
||||
player.play();
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user