react-lite-youtube-embed icon indicating copy to clipboard operation
react-lite-youtube-embed copied to clipboard

Add poster fallback quality

Open guilhermeleite-hotmart opened this issue 4 years ago • 5 comments
trafficstars

Problem If maxresdefault or sddefault poster quality doesn`t exist the video gets no thumbnail.

Suggestion Add fallback poster quality if the originally selected one is not available. If the api call return a 404 the component could try again using the fallback quality.

guilhermeleite-hotmart avatar Sep 16 '21 18:09 guilhermeleite-hotmart

@guilhermeleite-hotmart Could you please provide some links that doesn't have maxresdefault or sddefault in order to test a patch?

Thanks!

ibrahimcesar avatar Sep 17 '21 16:09 ibrahimcesar

Sure thing. Here's an example of a video that doens't have maxresdefault but has hqdefault thumbnail.

https://www.youtube.com/watch?v=jB20NKw3c6I

guilhermeleite-hotmart avatar Sep 17 '21 17:09 guilhermeleite-hotmart

@guilhermeleite-hotmart

I think this issue could be a little easier, but as turns out, is a little more complex:

  • The request for the image returns 404, but I just call the formatted URL for any specific image, I don't do this trough any form of API call, is a static request to the image
  • BUT, it returns an image (the placeholder one): https://i.ytimg.com/vi/jB20NKw3c6I/maxresdefault.jpg, and we return and display it, maybe I should check for an specific size (I found a thread on Stack Overflow), but I don't know if is error prone or not
  • If I tried to fetch it directly, I'm making another call likely doubling the number of requests.

The purpose of this lib is always trying to be as fast and as little resource wise on requests. I'll have to think a little more on that but in the meanwhile if have any kind of ideas, please let me know.

ibrahimcesar avatar Sep 18 '21 20:09 ibrahimcesar

Thanks for analyzing the issue and going through all the work to get back to me. I'll check the code and I'll try to come up with something if possible, even if just a suggestion.

guilhermeleite-hotmart avatar Sep 20 '21 14:09 guilhermeleite-hotmart

@ibrahimcesar Wouldn't it be possible to only use fetch and then use the resulting response (if successful) by putting it as a base64 encoded image as a thumbnail?

FunctionDJ avatar Apr 02 '22 22:04 FunctionDJ