From 9cf63609f4a89a231477daf4d61a8780c81c0cb2 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Tue, 21 May 2024 11:54:33 +0300 Subject: [PATCH 01/25] feature: add loaded prop --- src/WebOsVideo/WebOsVideo.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index 1987ac8..de1148a 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -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; @@ -419,6 +421,7 @@ function WebOsVideo(options) { var subtitlesOpacity = 100; var observedProps = { stream: false, + loaded: false, paused: false, time: false, duration: false, @@ -443,6 +446,9 @@ function WebOsVideo(options) { case 'stream': { return stream; } + case 'loaded': { + return isLoaded; + } case 'paused': { if (stream === null) { return null; @@ -951,6 +957,7 @@ function WebOsVideo(options) { onPropChanged('stream'); videoElement.autoplay = typeof commandArgs.autoplay === 'boolean' ? commandArgs.autoplay : true; + isLoaded = true; onPropChanged('paused'); onPropChanged('time'); onPropChanged('duration'); @@ -1028,6 +1035,7 @@ function WebOsVideo(options) { // console.log('webos video unload error'); // console.error(e); // } + isLoaded = false; onPropChanged('stream'); onPropChanged('paused'); onPropChanged('time'); @@ -1120,7 +1128,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'] }; From 5f4802f86a2b18e063f6fb4a23f4840c816c71c1 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Tue, 21 May 2024 12:03:23 +0300 Subject: [PATCH 02/25] refactor: move isloaded --- src/WebOsVideo/WebOsVideo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index de1148a..1e2fdd8 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -957,7 +957,6 @@ function WebOsVideo(options) { onPropChanged('stream'); videoElement.autoplay = typeof commandArgs.autoplay === 'boolean' ? commandArgs.autoplay : true; - isLoaded = true; onPropChanged('paused'); onPropChanged('time'); onPropChanged('duration'); @@ -995,6 +994,7 @@ function WebOsVideo(options) { try { videoElement.load(); + isLoaded = true; } catch(e) { // console.log('can\'t load video'); // console.error(e); From f4e38aab838514cda5296b839ada488017116bb3 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Tue, 21 May 2024 12:07:51 +0300 Subject: [PATCH 03/25] refactor: move isloaded (2) --- src/WebOsVideo/WebOsVideo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index 1e2fdd8..3237605 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -994,7 +994,6 @@ function WebOsVideo(options) { try { videoElement.load(); - isLoaded = true; } catch(e) { // console.log('can\'t load video'); // console.error(e); @@ -1012,6 +1011,7 @@ function WebOsVideo(options) { videoElement.src = stream.url; initMediaId(startVideo); + isLoaded = true; } else { onError(Object.assign({}, ERROR.UNSUPPORTED_STREAM, { critical: true, From b2a3ffb8691b90be63ea7c66d0546eea9d471448 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Tue, 21 May 2024 12:16:41 +0300 Subject: [PATCH 04/25] refactor: move isloaded (3) --- src/WebOsVideo/WebOsVideo.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index 3237605..58605e9 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -957,6 +957,8 @@ function WebOsVideo(options) { onPropChanged('stream'); videoElement.autoplay = typeof commandArgs.autoplay === 'boolean' ? commandArgs.autoplay : true; + isLoaded = true; + onPropChanged('loaded'); onPropChanged('paused'); onPropChanged('time'); onPropChanged('duration'); @@ -1011,7 +1013,6 @@ function WebOsVideo(options) { videoElement.src = stream.url; initMediaId(startVideo); - isLoaded = true; } else { onError(Object.assign({}, ERROR.UNSUPPORTED_STREAM, { critical: true, From 8d5b270c2d508b7a2b2ae04c6e2fa143f3640b97 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Tue, 21 May 2024 12:22:24 +0300 Subject: [PATCH 05/25] refactor: move isloaded (4) --- src/WebOsVideo/WebOsVideo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index 58605e9..2ff65f1 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -253,6 +253,7 @@ function WebOsVideo(options) { setSubs(info); setTracks(info); + isLoaded = true; unsubscribe(cb); } @@ -957,7 +958,6 @@ function WebOsVideo(options) { onPropChanged('stream'); videoElement.autoplay = typeof commandArgs.autoplay === 'boolean' ? commandArgs.autoplay : true; - isLoaded = true; onPropChanged('loaded'); onPropChanged('paused'); onPropChanged('time'); From 88ade027de830faf4d464070407cc9b443169485 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Tue, 21 May 2024 12:27:56 +0300 Subject: [PATCH 06/25] refactor: move isloaded (5) --- src/WebOsVideo/WebOsVideo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index 2ff65f1..07c16f3 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -253,7 +253,6 @@ function WebOsVideo(options) { setSubs(info); setTracks(info); - isLoaded = true; unsubscribe(cb); } @@ -974,6 +973,7 @@ function WebOsVideo(options) { var initMediaId = function (cb) { function retrieveMediaId() { if (videoElement.mediaId) { + isLoaded = true; knownMediaId = videoElement.mediaId; clearInterval(timer); subscribe(cb); From c7232f29d45e2f2d63f9920ebf83e3e157858563 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Tue, 21 May 2024 12:36:59 +0300 Subject: [PATCH 07/25] refactor: new try --- src/WebOsVideo/WebOsVideo.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index 07c16f3..4bb5015 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -974,6 +974,7 @@ function WebOsVideo(options) { function retrieveMediaId() { if (videoElement.mediaId) { isLoaded = true; + console.log('media id retrieved'); knownMediaId = videoElement.mediaId; clearInterval(timer); subscribe(cb); @@ -996,6 +997,8 @@ function WebOsVideo(options) { try { videoElement.load(); + isLoaded = true; + console.log('video loaded'); } catch(e) { // console.log('can\'t load video'); // console.error(e); @@ -1004,6 +1007,8 @@ function WebOsVideo(options) { try { // console.log('try play'); videoElement.play(); + isLoaded = true; + console.log('video playing'); } catch(e) { // console.log('can\'t start video'); // console.error(e); From bcc82c4fbe68b6040c5a542dde7e3b64692f2a69 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Tue, 21 May 2024 12:46:19 +0300 Subject: [PATCH 08/25] refactor: new 2 --- src/WebOsVideo/WebOsVideo.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index 4bb5015..0595121 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -973,8 +973,6 @@ function WebOsVideo(options) { var initMediaId = function (cb) { function retrieveMediaId() { if (videoElement.mediaId) { - isLoaded = true; - console.log('media id retrieved'); knownMediaId = videoElement.mediaId; clearInterval(timer); subscribe(cb); @@ -991,24 +989,21 @@ function WebOsVideo(options) { }; var startVideo = function () { - // console.log('startVideo'); + console.log('startVideo'); // not needed? // videoElement.src = stream.url; try { + console.log('try load'); videoElement.load(); - isLoaded = true; - console.log('video loaded'); } catch(e) { // console.log('can\'t load video'); // console.error(e); } try { - // console.log('try play'); + console.log('try play'); videoElement.play(); - isLoaded = true; - console.log('video playing'); } catch(e) { // console.log('can\'t start video'); // console.error(e); @@ -1017,6 +1012,7 @@ function WebOsVideo(options) { videoElement.src = stream.url; + console.log('initializing media id'); initMediaId(startVideo); } else { onError(Object.assign({}, ERROR.UNSUPPORTED_STREAM, { From 72673b18c35d0c6725ed8572e83e8c88ca11c4e6 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Tue, 21 May 2024 12:54:09 +0300 Subject: [PATCH 09/25] Revert "refactor: new 2" This reverts commit bcc82c4fbe68b6040c5a542dde7e3b64692f2a69. --- src/WebOsVideo/WebOsVideo.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index 0595121..4bb5015 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -973,6 +973,8 @@ function WebOsVideo(options) { var initMediaId = function (cb) { function retrieveMediaId() { if (videoElement.mediaId) { + isLoaded = true; + console.log('media id retrieved'); knownMediaId = videoElement.mediaId; clearInterval(timer); subscribe(cb); @@ -989,21 +991,24 @@ function WebOsVideo(options) { }; var startVideo = function () { - console.log('startVideo'); + // console.log('startVideo'); // not needed? // videoElement.src = stream.url; try { - console.log('try load'); videoElement.load(); + isLoaded = true; + console.log('video loaded'); } catch(e) { // console.log('can\'t load video'); // console.error(e); } try { - console.log('try play'); + // console.log('try play'); videoElement.play(); + isLoaded = true; + console.log('video playing'); } catch(e) { // console.log('can\'t start video'); // console.error(e); @@ -1012,7 +1017,6 @@ function WebOsVideo(options) { videoElement.src = stream.url; - console.log('initializing media id'); initMediaId(startVideo); } else { onError(Object.assign({}, ERROR.UNSUPPORTED_STREAM, { From e7e98dc5e891aa02c6c5323815f0458baa349a8a Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Tue, 21 May 2024 12:54:45 +0300 Subject: [PATCH 10/25] refactor: new approach --- src/WebOsVideo/WebOsVideo.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index 4bb5015..d1b6423 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -997,8 +997,6 @@ function WebOsVideo(options) { try { videoElement.load(); - isLoaded = true; - console.log('video loaded'); } catch(e) { // console.log('can\'t load video'); // console.error(e); @@ -1006,9 +1004,8 @@ function WebOsVideo(options) { try { // console.log('try play'); - videoElement.play(); isLoaded = true; - console.log('video playing'); + videoElement.play(); } catch(e) { // console.log('can\'t start video'); // console.error(e); From b449ae8cedb72f358025d7ab40c8000c71587f85 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Tue, 21 May 2024 12:55:29 +0300 Subject: [PATCH 11/25] remove: line 976 977 --- src/WebOsVideo/WebOsVideo.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index d1b6423..6e85837 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -973,8 +973,6 @@ function WebOsVideo(options) { var initMediaId = function (cb) { function retrieveMediaId() { if (videoElement.mediaId) { - isLoaded = true; - console.log('media id retrieved'); knownMediaId = videoElement.mediaId; clearInterval(timer); subscribe(cb); From 8e75f5efc85388430145540b18b6721bda963dfc Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Tue, 21 May 2024 12:56:40 +0300 Subject: [PATCH 12/25] add: logs --- src/WebOsVideo/WebOsVideo.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index 6e85837..27b55bd 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -1003,6 +1003,7 @@ function WebOsVideo(options) { try { // console.log('try play'); isLoaded = true; + console.log(isLoaded, 'video side loaded'); videoElement.play(); } catch(e) { // console.log('can\'t start video'); From 54b0d1864ae0fa58eb40db667aa7d36ace37f7e6 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Tue, 21 May 2024 13:39:05 +0300 Subject: [PATCH 13/25] refactor: add onpropchanged --- src/WebOsVideo/WebOsVideo.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index 27b55bd..33d8161 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -1003,6 +1003,7 @@ function WebOsVideo(options) { try { // console.log('try play'); isLoaded = true; + onPropChanged('loaded'); console.log(isLoaded, 'video side loaded'); videoElement.play(); } catch(e) { @@ -1039,6 +1040,7 @@ function WebOsVideo(options) { // } isLoaded = false; onPropChanged('stream'); + onPropChanged('loaded'); onPropChanged('paused'); onPropChanged('time'); onPropChanged('duration'); From c16a6025b5f0c1355844fc5af0171c88d19faff4 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Tue, 21 May 2024 13:52:12 +0300 Subject: [PATCH 14/25] refactor: remove lines 960 1007 --- src/WebOsVideo/WebOsVideo.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index 33d8161..c1abbce 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -957,7 +957,6 @@ function WebOsVideo(options) { onPropChanged('stream'); videoElement.autoplay = typeof commandArgs.autoplay === 'boolean' ? commandArgs.autoplay : true; - onPropChanged('loaded'); onPropChanged('paused'); onPropChanged('time'); onPropChanged('duration'); @@ -1004,7 +1003,6 @@ function WebOsVideo(options) { // console.log('try play'); isLoaded = true; onPropChanged('loaded'); - console.log(isLoaded, 'video side loaded'); videoElement.play(); } catch(e) { // console.log('can\'t start video'); From f960d67e20970a9b0127d8a3be35900cfa316617 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Tue, 21 May 2024 14:00:21 +0300 Subject: [PATCH 15/25] refactor: onpropcahnged --- src/WebOsVideo/WebOsVideo.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index c1abbce..8660eeb 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -957,6 +957,7 @@ function WebOsVideo(options) { onPropChanged('stream'); videoElement.autoplay = typeof commandArgs.autoplay === 'boolean' ? commandArgs.autoplay : true; + onPropChanged('loaded'); onPropChanged('paused'); onPropChanged('time'); onPropChanged('duration'); @@ -1002,7 +1003,7 @@ function WebOsVideo(options) { try { // console.log('try play'); isLoaded = true; - onPropChanged('loaded'); + // onPropChanged('loaded'); videoElement.play(); } catch(e) { // console.log('can\'t start video'); From de57114b0f91588a56c911b64afd178ad276a41f Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Tue, 21 May 2024 14:04:26 +0300 Subject: [PATCH 16/25] refactor: add oppropchanged 1006 again --- src/WebOsVideo/WebOsVideo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index 8660eeb..697f0a5 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -1003,7 +1003,7 @@ function WebOsVideo(options) { try { // console.log('try play'); isLoaded = true; - // onPropChanged('loaded'); + onPropChanged('loaded'); videoElement.play(); } catch(e) { // console.log('can\'t start video'); From fba22a37bfc43ea7dff3783b455b0fe6e10742d2 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Tue, 21 May 2024 14:13:02 +0300 Subject: [PATCH 17/25] lint: remove trailing space --- src/WebOsVideo/WebOsVideo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index 697f0a5..0088afe 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -150,7 +150,7 @@ function WebOsVideo(options) { throw new Error('Container element required to be instance of HTMLElement'); } - var isLoaded = null; + var isLoaded = null; var knownMediaId = false; From 9fb01bab23e58f214e657d3d241342e68c74528b Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Tue, 21 May 2024 14:32:01 +0300 Subject: [PATCH 18/25] refactor: add logs again --- src/WebOsVideo/WebOsVideo.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index 0088afe..6dd8115 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -989,11 +989,14 @@ function WebOsVideo(options) { }; var startVideo = function () { - // console.log('startVideo'); + console.log('startVideo'); // not needed? // videoElement.src = stream.url; try { + isLoaded = true; + onPropChanged('loaded'); + console.log(isLoaded, 'video element load'); // eslint-disable-line no-console videoElement.load(); } catch(e) { // console.log('can\'t load video'); @@ -1004,6 +1007,7 @@ function WebOsVideo(options) { // console.log('try play'); isLoaded = true; onPropChanged('loaded'); + console.log(isLoaded, 'video element play'); // eslint-disable-line no-console videoElement.play(); } catch(e) { // console.log('can\'t start video'); From 6f1edfb92a02deb10c179e2fb4c66abe4daa3a57 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Wed, 22 May 2024 11:40:11 +0300 Subject: [PATCH 19/25] feature: add logs for debugging --- src/WebOsVideo/WebOsVideo.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index 1987ac8..e5595f6 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -247,6 +247,7 @@ function WebOsVideo(options) { if (result.sourceInfo && !answered) { answered = true; var info = result.sourceInfo.programInfo[0]; + console.log('sourceInfofrom subscribe function ', info); // eslint-disable-line no-console setSubs(info); @@ -267,7 +268,7 @@ function WebOsVideo(options) { if ((result.unloadCompleted || {}).mediaId === knownMediaId && (result.unloadCompleted || {}).state) { // strange case where it just.. ends? without ever getting result.sourceInfo // onEnded(); - // console.log('strange case of end'); + console.log('strange case of end', knownMediaId); // eslint-disable-line no-console // unsubscribe(cb); return; } @@ -965,15 +966,17 @@ function WebOsVideo(options) { var initMediaId = function (cb) { function retrieveMediaId() { + console.log('retrieveMediaId run'); // eslint-disable-line no-console if (videoElement.mediaId) { knownMediaId = videoElement.mediaId; + console.log('knownMediaId retrievemediaid', knownMediaId); // eslint-disable-line no-console clearInterval(timer); subscribe(cb); return; } count++; if (count > 4) { - // console.log('failed to get media id'); + console.log('failed to get media id count > 4'); // eslint-disable-line no-console clearInterval(timer); cb(); } @@ -982,20 +985,31 @@ function WebOsVideo(options) { }; var startVideo = function () { - // console.log('startVideo'); + console.log('startVideo run'); // eslint-disable-line no-console + console.log(videoElement.mediaId, 'on startvideo func'); // eslint-disable-line no-console + console.log(knownMediaId, 'knownMediaId plaon start func'); // eslint-disable-line no-console // not needed? // 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 videoElement.load(); + console.log('videoElement.load() run'); // eslint-disable-line no-console + console.log(knownMediaId, 'knownMediaId after load'); // eslint-disable-line no-console + console.log(videoElement.mediaId, 'after load'); // eslint-disable-line no-console } catch(e) { // console.log('can\'t load video'); // console.error(e); } try { - // console.log('try play'); + console.log(videoElement.mediaId, 'before play'); // eslint-disable-line no-console + console.log(knownMediaId, 'knownMediaId before 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 + console.log(videoElement.mediaId), 'after play'; // eslint-disable-line no-console } catch(e) { // console.log('can\'t start video'); // console.error(e); From 5c7530fdea8cd4c878a1d8566ffc57c38ff75f38 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Wed, 22 May 2024 12:12:21 +0300 Subject: [PATCH 20/25] feature: add logs in subscribe fn --- src/WebOsVideo/WebOsVideo.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index e5595f6..c64aa7f 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -244,6 +244,7 @@ function WebOsVideo(options) { 'subscribe': true } }, function (result) { + console.log('luna playback result before result.sourceInfo', result); // eslint-disable-line no-console if (result.sourceInfo && !answered) { answered = true; var info = result.sourceInfo.programInfo[0]; @@ -254,11 +255,13 @@ function WebOsVideo(options) { setTracks(info); unsubscribe(cb); + } else { + console.log('luna playback result when sourceInfo is not found', result); // eslint-disable-line no-console } if ((result.error || {}).errorCode) { answered = true; - // console.error('luna playback error', result.error); + console.error('luna playback error', result.error); // eslint-disable-line no-console unsubscribe(cb); // unsubscribe(); // onVideoError(); From d214adf096e8860583b81051d8dc431720c581fe Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Wed, 22 May 2024 12:35:25 +0300 Subject: [PATCH 21/25] feature: add retries --- src/WebOsVideo/WebOsVideo.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index c64aa7f..3b7fda9 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -256,7 +256,36 @@ function WebOsVideo(options) { unsubscribe(cb); } else { - console.log('luna playback result when sourceInfo is not found', result); // eslint-disable-line no-console + luna({ + method: 'subscribe', + parameters: { + 'mediaId': knownMediaId, + 'subscribe': true + } + }, function (result) { + console.log('luna playback result before result.sourceInfo in the else statement', result); // eslint-disable-line no-console + if (result.sourceInfo && !answered) { + answered = true; + var info = result.sourceInfo.programInfo[0]; + console.log('sourceInfofrom subscribe function in the else statement', info); // eslint-disable-line no-console + + setSubs(info); + + setTracks(info); + + unsubscribe(cb); + } + + if ((result.error || {}).errorCode) { + answered = true; + console.error('luna playback error', result.error); // eslint-disable-line no-console + unsubscribe(cb); + // unsubscribe(); + // onVideoError(); + return; + } + } + ); } if ((result.error || {}).errorCode) { From ec882e5520598b1720eb08418d7cd5ae3d7f5117 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Wed, 22 May 2024 12:57:40 +0300 Subject: [PATCH 22/25] update: logs --- src/WebOsVideo/WebOsVideo.js | 38 +++++------------------------------- 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index 3b7fda9..70ded7e 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -212,6 +212,7 @@ function WebOsVideo(options) { if (info.numAudioTracks) { for (var i = 0; i < info.audioTrackInfo.length; i++) { var audioTrack = info.audioTrackInfo[i]; + console.log('audioTrack', audioTrack, i); // eslint-disable-line no-console audioTrack.index = i; var audioTrackId = 'EMBEDDED_' + audioTrack.index; if (!currentAudioTrack && !audioTracks.length) { @@ -244,7 +245,7 @@ function WebOsVideo(options) { 'subscribe': true } }, function (result) { - console.log('luna playback result before result.sourceInfo', result); // eslint-disable-line no-console + console.log('luna playback result before result.source', result); // eslint-disable-line no-console if (result.sourceInfo && !answered) { answered = true; var info = result.sourceInfo.programInfo[0]; @@ -255,42 +256,13 @@ function WebOsVideo(options) { setTracks(info); unsubscribe(cb); - } else { - luna({ - method: 'subscribe', - parameters: { - 'mediaId': knownMediaId, - 'subscribe': true - } - }, function (result) { - console.log('luna playback result before result.sourceInfo in the else statement', result); // eslint-disable-line no-console - if (result.sourceInfo && !answered) { - answered = true; - var info = result.sourceInfo.programInfo[0]; - console.log('sourceInfofrom subscribe function in the else statement', info); // eslint-disable-line no-console - - setSubs(info); - - setTracks(info); - - unsubscribe(cb); - } - - if ((result.error || {}).errorCode) { - answered = true; - console.error('luna playback error', result.error); // eslint-disable-line no-console - unsubscribe(cb); - // unsubscribe(); - // onVideoError(); - return; - } - } - ); + } else if (result.sourceInfo) { + console.log('luna playback result', result); // eslint-disable-line no-console } if ((result.error || {}).errorCode) { answered = true; - console.error('luna playback error', result.error); // eslint-disable-line no-console + // console.error('luna playback error', result.error); unsubscribe(cb); // unsubscribe(); // onVideoError(); From 86a7507692956be0a1dc75ccd525fa32629ca09c Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Mon, 27 May 2024 13:13:20 +0300 Subject: [PATCH 23/25] refactor: add buffer range check --- src/WebOsVideo/WebOsVideo.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index 6788669..28c3d79 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -279,11 +279,12 @@ function WebOsVideo(options) { return; } - count_message++; + if(result.bufferRange) { + count_message++; - if (count_message === 30 && !answered) { - // cb(); - unsubscribe(cb); + if (count_message === 30 && !answered) { + unsubscribe(cb); + } } }, function() { // function(err) // console.log('luna error log 2'); From 74e42a4ec7c00a819aad380c9b862fe412fa3c29 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Mon, 27 May 2024 14:10:03 +0300 Subject: [PATCH 24/25] add: err function in subscribe --- src/WebOsVideo/WebOsVideo.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index 28c3d79..b4f1c4a 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -286,9 +286,9 @@ function WebOsVideo(options) { unsubscribe(cb); } } - }, function() { // function(err) + }, function(err) { // function(err) // console.log('luna error log 2'); - // console.error(err); + console.error(err); // eslint-disable-line no-console }); }; From 18e34dbfea5b197819b48ef6a7c9ccdac36a7cbf Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Mon, 27 May 2024 14:10:30 +0300 Subject: [PATCH 25/25] add: console log err placement --- src/WebOsVideo/WebOsVideo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index b4f1c4a..ba7ea14 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -287,7 +287,7 @@ function WebOsVideo(options) { } } }, function(err) { // function(err) - // console.log('luna error log 2'); + console.log('luna error log 2'); // eslint-disable-line no-console console.error(err); // eslint-disable-line no-console }); };