sampotts / plyr

A simple HTML5, YouTube and Vimeo player
https://plyr.io
MIT License
26.42k stars 2.92k forks source link

Can't load src dynamically #2057

Open Gricardov opened 3 years ago

Gricardov commented 3 years ago

Hi team. I'm loading urls dynamically when I click a button. However, the player loses its custom UI.

Expected behaviour

The player should keep its UI when I update the src of the iframe

Actual behaviour

The player shows the tipical YouTube UI

Steps to reproduce

This is the code I'm using on React. The links are updated inside a hook

useEffect(() => { const episode = episodes.find(episode => episode .id === activeId); if (episode ) { setVideoUrl(https://www.youtube.com/embed/${urlVideo}?origin=https://plyr.io&iv_load_policy=3&modestbranding=1&playsinline=1&showinfo=0&rel=0&enablejsapi=1); } }, [activeId, videoUrl])

Environment

Console errors (if any)

Link to where the bug is happening

image

ametthey commented 3 years ago

Nobody found a solution for this ? I'm trying to achieve the same thing, well kinda, for a wordpress site where I get my youtube ID from a URL and then I do the same as the estUrlVideo function above but it's not working @sampotts did you encounter anything related ?

Thanks a lot for the answer ! :D

amaank404 commented 3 years ago

Same here trying to use load method (to reload a video for scaring a person with horror video) but that is not available with plyr but it is available with default video tag

/cc: @sampotts

Gricardov commented 3 years ago

Hi chamos, good news! I actually found a solution months ago. This is the sample file: https://github.com/AcademiaTemple/website-react/blob/master/src/pages/course-player.js

And this is the live result: https://academiatemple.com/course-player/?id=IrnTmomFcr5EGtcMVFGd&episode=3UJBFdPBQuLjGAwxAuN4

You are welcome!

amaank404 commented 3 years ago

so solution is to create a new plyer and replace it with original object.

amaank404 commented 3 years ago

but anyways it would be just better if it was builtin to reload. Thanks for the workaround 😄