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

add onError in Poster img tag #1527

Open
sytolk opened this issue Dec 3, 2024 · 0 comments
Open

add onError in Poster img tag #1527

sytolk opened this issue Dec 3, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@sytolk
Copy link

sytolk commented Dec 3, 2024

I have React project with <Poster onError={} /> this render <img> tag but without onError. I want if poster src not exist to not shown broken image icon. This is my code:

<MediaPlayer
          viewType={isAudioType() ? 'audio' : 'video'}
          autoPlay={autoPlay.current}
          loop={loop.current === 'loopOne'}
          className="player"
          title={extractFileName(filePath)}
          src={filePath}
          crossOrigin
          playsInline
          onEnded={onEnded}
          ref={player}
        >
          <MediaProvider>
            <Poster
              className="vds-poster"
              src={
               getThumbFileLocationForFile(filePath)
              }
              onError={(i: SyntheticEvent<EventTarget>) => {
                const target = i.target as HTMLImageElement;
                target.style.display = 'none'
              }}
              alt={filePath}
            />
          </MediaProvider>

          {/* Layouts */}
          <DefaultAudioLayout icons={defaultLayoutIcons} />
          <DefaultVideoLayout
            icons={defaultLayoutIcons}
            // thumbnails="https://files.vidstack.io/sprite-fight/thumbnails.vtt"
          />
        </MediaPlayer>

You can repeat this issue here: https://github.com/vidstack/examples/blob/main/player/react/default-layout/src/player.tsx#L88

@sytolk sytolk added the bug Something isn't working label Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant