Skip to content

Commit

Permalink
feat: loading icon in video (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhassan8 authored Sep 11, 2023
1 parent 753b765 commit 6510be6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 166 deletions.
167 changes: 2 additions & 165 deletions server/js/core/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ window.player = {
config: function (timeFunction, endFunction) {
player.getVideo().addEventListener("timeupdate", timeFunction);
player.getVideo().addEventListener("ended", endFunction);
player.getVideo().addEventListener('waiting', player.onbufferingstart);
player.getVideo().addEventListener('playing', player.onbufferingcomplete);
},

getPlayed: function () {
Expand All @@ -42,167 +44,6 @@ window.player = {
player.plugin = new Hls();
player.plugin.loadSource(url);
player.plugin.attachMedia(player.getVideo());

// player.plugin.on(Hls.Events.MANIFEST_PARSED, function () {
// console.log("MANIFEST_PARSED");
// });

// player.plugin.on(Hls.Events.MEDIA_ATTACHING, function () {
// console.log("MEDIA_ATTACHING");
// });
// player.plugin.on(Hls.Events.MEDIA_ATTACHED, function () {
// console.log("MEDIA_ATTACHED");
// });
// player.plugin.on(Hls.Events.MEDIA_DETACHING, function () {
// console.log("MEDIA_DETACHING");
// });
// player.plugin.on(Hls.Events.MEDIA_DETACHED, function () {
// console.log("MEDIA_DETACHED");
// });
// player.plugin.on(Hls.Events.BUFFER_RESET, function () {
// console.log("BUFFER_RESET");
// });
// player.plugin.on(Hls.Events.BUFFER_CODECS, function () {
// console.log("BUFFER_CODECS");
// });
// player.plugin.on(Hls.Events.BUFFER_CREATED, function () {
// console.log("BUFFER_CREATED");
// });
// player.plugin.on(Hls.Events.BUFFER_APPENDING, function () {
// console.log("BUFFER_APPENDING");
// });
// player.plugin.on(Hls.Events.BUFFER_APPENDED, function () {
// console.log("BUFFER_APPENDED");
// });
// player.plugin.on(Hls.Events.BUFFER_EOS, function () {
// console.log("BUFFER_EOS");
// });
// player.plugin.on(Hls.Events.BUFFER_FLUSHING, function () {
// console.log("BUFFER_FLUSHING");
// });
// player.plugin.on(Hls.Events.BUFFER_FLUSHED, function () {
// console.log("BUFFER_FLUSHED");
// });
// player.plugin.on(Hls.Events.MANIFEST_LOADING, function () {
// console.log("MANIFEST_LOADING");
// });
// player.plugin.on(Hls.Events.MANIFEST_LOADED, function () {
// console.log("MANIFEST_LOADED");
// });
// player.plugin.on(Hls.Events.LEVEL_SWITCHING, function () {
// console.log("LEVEL_SWITCHING");
// });
// player.plugin.on(Hls.Events.LEVEL_SWITCHED, function () {
// console.log("LEVEL_SWITCHED");
// });
// player.plugin.on(Hls.Events.LEVEL_LOADING, function () {
// console.log("LEVEL_LOADING");
// });
// player.plugin.on(Hls.Events.LEVEL_LOADED, function () {
// console.log("LEVEL_LOADED");
// });
// player.plugin.on(Hls.Events.LEVEL_UPDATED, function () {
// console.log("LEVEL_UPDATED");
// });
// player.plugin.on(Hls.Events.LEVEL_PTS_UPDATED, function () {
// console.log("LEVEL_PTS_UPDATED");
// });
// player.plugin.on(Hls.Events.LEVELS_UPDATED, function () {
// console.log("LEVELS_UPDATED");
// });
// player.plugin.on(Hls.Events.AUDIO_TRACKS_UPDATED, function () {
// console.log("AUDIO_TRACKS_UPDATED");
// });
// player.plugin.on(Hls.Events.AUDIO_TRACK_SWITCHING, function () {
// console.log("AUDIO_TRACK_SWITCHING");
// });
// player.plugin.on(Hls.Events.AUDIO_TRACK_SWITCHED, function () {
// console.log("AUDIO_TRACK_SWITCHED");
// });
// player.plugin.on(Hls.Events.AUDIO_TRACK_LOADING, function () {
// console.log("AUDIO_TRACK_LOADING");
// });
// player.plugin.on(Hls.Events.AUDIO_TRACK_LOADED, function () {
// console.log("AUDIO_TRACK_LOADED");
// });
// player.plugin.on(Hls.Events.SUBTITLE_TRACKS_UPDATED, function () {
// console.log("SUBTITLE_TRACKS_UPDATED");
// });
// player.plugin.on(Hls.Events.SUBTITLE_TRACKS_CLEARED, function () {
// console.log("SUBTITLE_TRACKS_CLEARED");
// });
// player.plugin.on(Hls.Events.SUBTITLE_TRACK_SWITCH, function () {
// console.log("SUBTITLE_TRACK_SWITCH");
// });
// player.plugin.on(Hls.Events.SUBTITLE_TRACK_LOADING, function () {
// console.log("SUBTITLE_TRACK_LOADING");
// });
// player.plugin.on(Hls.Events.SUBTITLE_TRACK_LOADED, function () {
// console.log("SUBTITLE_TRACK_LOADED");
// });
// player.plugin.on(Hls.Events.SUBTITLE_FRAG_PROCESSED, function () {
// console.log("SUBTITLE_FRAG_PROCESSED");
// });
// player.plugin.on(Hls.Events.CUES_PARSED, function () {
// console.log("CUES_PARSED");
// });
// player.plugin.on(Hls.Events.NON_NATIVE_TEXT_TRACKS_FOUND, function () {
// console.log("NON_NATIVE_TEXT_TRACKS_FOUND");
// });
// player.plugin.on(Hls.Events.INIT_PTS_FOUND, function () {
// console.log("INIT_PTS_FOUND");
// });
// player.plugin.on(Hls.Events.FRAG_LOADING, function () {
// console.log("FRAG_LOADING");
// });
// player.plugin.on(Hls.Events.FRAG_LOAD_EMERGENCY_ABORTED, function () {
// console.log("FRAG_LOAD_EMERGENCY_ABORTED");
// });
// player.plugin.on(Hls.Events.FRAG_LOADED, function () {
// console.log("FRAG_LOADED");
// });
// player.plugin.on(Hls.Events.FRAG_DECRYPTED, function () {
// console.log("FRAG_DECRYPTED");
// });
// player.plugin.on(Hls.Events.FRAG_PARSING_INIT_SEGMENT, function () {
// console.log("FRAG_PARSING_INIT_SEGMENT");
// });
// player.plugin.on(Hls.Events.FRAG_PARSING_USERDATA, function () {
// console.log("FRAG_PARSING_USERDATA");
// });
// player.plugin.on(Hls.Events.FRAG_PARSING_METADATA, function () {
// console.log("FRAG_PARSING_METADATA");
// });
// player.plugin.on(Hls.Events.FRAG_PARSED, function () {
// console.log("FRAG_PARSED");
// });
// player.plugin.on(Hls.Events.FRAG_BUFFERED, function () {
// console.log("FRAG_BUFFERED");
// });
// player.plugin.on(Hls.Events.FRAG_CHANGED, function () {
// console.log("FRAG_CHANGED");
// });
// player.plugin.on(Hls.Events.FPS_DROP, function () {
// console.log("FPS_DROP");
// });
// player.plugin.on(Hls.Events.FPS_DROP_LEVEL_CAPPING, function () {
// console.log("FPS_DROP_LEVEL_CAPPING");
// });
// player.plugin.on(Hls.Events.ERROR, function () {
// console.log("ERROR");
// });
// player.plugin.on(Hls.Events.DESTROYING, function () {
// console.log("DESTROYING");
// });
// player.plugin.on(Hls.Events.KEY_LOADING, function () {
// console.log("KEY_LOADING");
// });
// player.plugin.on(Hls.Events.KEY_LOADED, function () {
// console.log("KEY_LOADED");
// });
// player.plugin.on(Hls.Events.LIVE_BACK_BUFFER_REACHED, function () {
// console.log("LIVE_BACK_BUFFER_REACHED");
// });
} else if (player.getVideo().canPlayType("application/vnd.apple.mpegurl")) {
player.getVideo().src = url;
}
Expand Down Expand Up @@ -293,10 +134,6 @@ window.player = {
video.showBTN("loading");
},

onbufferingprogress: function (percent) {
video.showBTN("loading", `${percent} %`);
},

onbufferingcomplete: function () {
video.hideBTN();
},
Expand Down
1 change: 0 additions & 1 deletion server/js/screen/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,6 @@ window.video = {
var button = document.getElementById("osd-icon");
button.style.opacity = 1;
button.className = `icon-status ${state}`;
document.getElementById("osd-icon-data").innerText = data;
},

hideBTN: function () {
Expand Down

0 comments on commit 6510be6

Please sign in to comment.