Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added event dispatch for youtube errors #78

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Jerricho93
Copy link

@Jerricho93 Jerricho93 commented Feb 6, 2025

Fixes #57

Added

  • dispatchEvent() call to the errors for YouTube
  • addEventListener('error') to display it in the console in the YouTube video element

The following screenshot displays how, given an issue with the YouTube video, the console will display the error with all the information
image

Copy link

vercel bot commented Feb 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
media-elements-nextjs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 11, 2025 5:54pm

@R-Delfino95
Copy link

LGTM!

onError: (error) => console.error(error),
onError: (error) => {
console.error(error);
this.dispatchEvent(new CustomEvent('error', { detail: error }));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know this can be handy but the native video API doesn't pass any data with the event. I think we should stay 1:1 as much as possible so a new Event('error') and then store the last error in a variable and return it in a get error() property

Copy link
Collaborator

@luwes luwes left a comment

Choose a reason for hiding this comment

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

This is great but best to stay as close as possible to the native API.

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.

[YouTube] dispatch the error event
3 participants