Skip to content

Commit

Permalink
Merge branch 'feature-loaded-prop' into webos-player-rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
kKaskak committed May 22, 2024
2 parents ec882e5 + 9fb01ba commit 4838c72
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/WebOsVideo/WebOsVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ function WebOsVideo(options) {
throw new Error('Container element required to be instance of HTMLElement');
}

var isLoaded = null;

var knownMediaId = false;

var subSize = 75;
Expand Down Expand Up @@ -424,6 +426,7 @@ function WebOsVideo(options) {
var subtitlesOpacity = 100;
var observedProps = {
stream: false,
loaded: false,
paused: false,
time: false,
duration: false,
Expand All @@ -448,6 +451,9 @@ function WebOsVideo(options) {
case 'stream': {
return stream;
}
case 'loaded': {
return isLoaded;
}
case 'paused': {
if (stream === null) {
return null;
Expand Down Expand Up @@ -956,6 +962,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 @@ -996,8 +1003,9 @@ function WebOsVideo(options) {
// videoElement.src = stream.url;

try {
console.log(videoElement.mediaId, 'before load'); // eslint-disable-line no-console
console.log(knownMediaId, 'knownMediaId before load'); // eslint-disable-line no-console
isLoaded = true;
onPropChanged('loaded');
console.log(isLoaded, 'video element load'); // eslint-disable-line no-console
videoElement.load();
console.log('videoElement.load() run'); // eslint-disable-line no-console
console.log(knownMediaId, 'knownMediaId after load'); // eslint-disable-line no-console
Expand All @@ -1008,8 +1016,10 @@ function WebOsVideo(options) {
}

try {
console.log(videoElement.mediaId, 'before play'); // eslint-disable-line no-console
console.log(knownMediaId, 'knownMediaId before play'); // eslint-disable-line no-console
// console.log('try play');
isLoaded = true;
onPropChanged('loaded');
console.log(isLoaded, 'video element play'); // eslint-disable-line no-console
videoElement.play();
console.log('videoElement.play() run'); // eslint-disable-line no-console
console.log(knownMediaId, 'knownMediaId after play'); // eslint-disable-line no-console
Expand Down Expand Up @@ -1046,7 +1056,9 @@ function WebOsVideo(options) {
// console.log('webos video unload error');
// console.error(e);
// }
isLoaded = false;
onPropChanged('stream');
onPropChanged('loaded');
onPropChanged('paused');
onPropChanged('time');
onPropChanged('duration');
Expand Down Expand Up @@ -1138,7 +1150,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 4838c72

Please sign in to comment.