shiyiya / oplayer

:zap: Another HTM5 video player.
https://oplayer.vercel.app
MIT License
147 stars 19 forks source link

React package does not work with React SSR #4

Closed phpb-com closed 2 years ago

phpb-com commented 2 years ago

Hi, I have tried to use oplayer with Remix and could not start the server due to a lot of errors. It seems that the server-side code is trying to access window.document which does not exist. If you want me to provide you with the reproduction case, I can make a sample repo.

shiyiya commented 2 years ago

Currently, SSR is not supported.

This is my current solution.

https://github.com/shiyiya/oplayer/blob/main/website/src/components/Playground/index.jsx#L8

phpb-com commented 2 years ago

Thanks for the link. Do you plan to address this issue in the future?

shiyiya commented 2 years ago

This may take some time. Of course, if you are willing to help, welcome PR. Thanks.

shiyiya commented 2 years ago

Updated f611402d0a2898a368d04c2cb03dd4afa65db1d8

Try v1.0.20

https://github.com/shiyiya/oplayer/blob/main/website/src/components/Playground/index.jsx

If used react >= 18, can use @oplayer/react

phpb-com commented 2 years ago

You are the best, I'll try it and see if it works and confirm here.

phpb-com commented 2 years ago

Can confirm that I have a basic capabilities working, and even was able to deploy to Cloudflare Pages with Remix app. I will need to do more tests to give you more data. Thanks for such a quick turn-around.

phpb-com commented 2 years ago

Found one bug, HLS playback does not work on the iPhone. Only works when autoplay is set to true

phpb-com commented 2 years ago

btw, I think it is safe to resolve this. SSR has no issues that I could detect. Unless you have other areas you wanted to address. Thanks again for such a quick fix of a stopper.