Skip to content

Conversation

@jakub-roch
Copy link
Contributor

Add live stream error screen when type === 'live' & auto refresh every 10 seconds

@jakub-roch jakub-roch requested a review from a team as a code owner February 17, 2025 13:27
@netlify
Copy link

netlify bot commented Feb 17, 2025

Deploy Preview for cld-video-player ready!

Name Link
🔨 Latest commit 214e9fc
🔍 Latest deploy log https://app.netlify.com/sites/cld-video-player/deploys/67befa0c49eaa3000877725f
😎 Deploy Preview https://deploy-preview-819--cld-video-player.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Feb 17, 2025

Deploy Preview for cld-vp-esm-pages ready!

Name Link
🔨 Latest commit 214e9fc
🔍 Latest deploy log https://app.netlify.com/sites/cld-vp-esm-pages/deploys/67befa0cf45d38000815f74a
😎 Deploy Preview https://deploy-preview-819--cld-vp-esm-pages.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Comment on lines 138 to 158
_setRetryForLiveStream(delaySeconds = 10) {
const tempVideo = document.createElement('video');
tempVideo.setAttribute('crossorigin', 'anonymous');
const liveStreamUrl = this.currentSourceUrl();

const retryLiveStreamLoad = () => {
setTimeout(() => {
tempVideo.src = liveStreamUrl;
tempVideo.load();
}, delaySeconds * 1000);
};

tempVideo.onprogress = () => {
tempVideo.onerror = null;
tempVideo.oncanplaythrough = null;
this.source(liveStreamUrl);
};
tempVideo.onerror = retryLiveStreamLoad;

retryLiveStreamLoad();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jakub-roch we already have a reTryVideo handler.
can we re-use that instead?
https://github.com/cloudinary/cloudinary-video-player/blob/master/src/video-player.js#L418

width: playerOptions.width,
withCredentials: playerOptions.withCredentials,
debug: playerOptions.debug,
type: playerOptions.type,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💪

Copy link
Collaborator

@tsi tsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jakub-roch looks much better.
I'm approving to unblock you but please see my comments

Comment on lines 584 to 585
const maxTries = this.videojs.options_.maxTries || 3;
const videoReadyTimeout = this.videojs.options_.videoTimeout || 55000;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these also use the RETRY_DEFAULT_TIMEOUT const?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not sure abut changing it - will check it to make sure we can replace it with RETRY_DEFAULT_TIMEOUT

Comment on lines 48 to 54
videoPlayerInstance = cloudinary.videoPlayer('player', {
cloudName,
publicId: liveStreamingUrl,
type: 'live',
controls: true,
sourceTypes: ['hls'],
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of an empty player, can we show something like this example by default? better if it comes from demo/prod cloud

if (s >= (/iPad|iPhone|iPod/.test(navigator.userAgent) ? 1 : 4)) {
this.nbCalls = 0;
return true;
reloadVideoUntilAvailable(maxNumberOfCalls = Number.POSITIVE_INFINITY, timeout = RETRY_DEFAULT_TIMEOUT) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to try this until infinity by default? can't this create issues?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont see a reason why not - it makes sure that until user close tab / browser it will still re-try to load video
it just repeats fetch calls for video to see if its available

}

return false;
if (this.reloadVideoRetriesCount < maxNumberOfCalls) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this.reloadVideoRetriesCount? is there supposed to be a this.reloadVideoRetriesCount++ somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch, I missed it 👍

this.videoElement = getResolveVideoElement(elem);

this.options = extractOptions(this.videoElement, initOptions);
this.isLiveStream = this.options.videojsOptions.type === 'live';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we set this as part of player constructor? Imean, the initial source can be live but the same player can switch to other sources that are not.
Here we do source.resourceConfig().type === 'live', would that be better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, I added isLiveStream fn that is called every time to check current type 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anyway its edge case that type of live will be changed but anyway good to handle it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants