Skip to content

Commit

Permalink
Merge pull request #81 from Stremio/lg-loaded-event
Browse files Browse the repository at this point in the history
Handle Loaded Event for LG
  • Loading branch information
jaruba authored May 31, 2024
2 parents 7c15bb7 + 1014bb9 commit 6e6a67c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/WebOsVideo/WebOsVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ function WebOsVideo(options) {
throw new Error('Container element required to be instance of HTMLElement');
}

var isLoaded = false;

var knownMediaId = false;

var subSize = 75;
Expand Down Expand Up @@ -366,6 +368,10 @@ function WebOsVideo(options) {
videoElement.onplaying = function() {
onPropChanged('buffering');
onPropChanged('buffered');
if (!isLoaded) {
isLoaded = true;
onPropChanged('loaded');
}
};
videoElement.oncanplay = function() {
onPropChanged('buffering');
Expand Down Expand Up @@ -413,6 +419,7 @@ function WebOsVideo(options) {
var subtitlesOpacity = 100;
var observedProps = {
stream: false,
loaded: false,
paused: false,
time: false,
duration: false,
Expand All @@ -437,6 +444,9 @@ function WebOsVideo(options) {
case 'stream': {
return stream;
}
case 'loaded': {
return isLoaded;
}
case 'paused': {
if (stream === null) {
return null;
Expand Down Expand Up @@ -945,6 +955,7 @@ function WebOsVideo(options) {
onPropChanged('stream');
videoElement.autoplay = typeof commandArgs.autoplay === 'boolean' ? commandArgs.autoplay : true;

onPropChanged('loaded');
onPropChanged('paused');
onPropChanged('time');
onPropChanged('duration');
Expand Down Expand Up @@ -1114,7 +1125,7 @@ WebOsVideo.canPlayStream = function() { // function(stream)
WebOsVideo.manifest = {
name: 'WebOsVideo',
external: false,
props: ['stream', 'paused', 'time', 'duration', 'buffering', 'buffered', 'audioTracks', 'selectedAudioTrackId', 'subtitlesTracks', 'selectedSubtitlesTrackId', 'subtitlesOffset', 'subtitlesSize', 'subtitlesTextColor', 'subtitlesBackgroundColor', 'subtitlesOpacity', 'volume', 'muted', 'playbackSpeed'],
props: ['stream', 'loaded', 'paused', 'time', 'duration', 'buffering', 'buffered', 'audioTracks', 'selectedAudioTrackId', 'subtitlesTracks', 'selectedSubtitlesTrackId', 'subtitlesOffset', 'subtitlesSize', 'subtitlesTextColor', 'subtitlesBackgroundColor', 'subtitlesOpacity', 'volume', 'muted', 'playbackSpeed'],
commands: ['load', 'unload', 'destroy'],
events: ['propValue', 'propChanged', 'ended', 'error', 'subtitlesTrackLoaded', 'audioTrackLoaded']
};
Expand Down

0 comments on commit 6e6a67c

Please sign in to comment.