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

react-to-print does not wait for videos to load #439

Closed
Tian94 opened this issue Nov 24, 2021 · 4 comments
Closed

react-to-print does not wait for videos to load #439

Tian94 opened this issue Nov 24, 2021 · 4 comments

Comments

@Tian94
Copy link

Tian94 commented Nov 24, 2021

Hi there

I'm using react-to-print to print a page which has some video elements on it. At the moment it loads the video component but doesn't wait for the thumbnail of the video to load.

I've tried to use onBeforePrint to wait until the loadeddata events of the videos have all run but it doesn't seem to work. I'm guessing it won't be possible without updating the react-to-print source code to wait for the video thumbnails to load similar to what's being done for images here? https://github.com/gregnb/react-to-print/blob/master/src/index.tsx#L320

Please let me know if I'm correct or if there is a way of waiting for videos to load.

Thank you!

@MatthewHerbst
Copy link
Owner

Hello. Thanks for reporting the issue. Have you tried with onBeforeGetContent? But you are correct we don't do anything special currently, and we probably should! Could you possibly make a small demo on codesandbox showing the issue so I can debug properly for your use-case? Thank you

@Tian94
Copy link
Author

Tian94 commented Nov 24, 2021

Thank you @MatthewHerbst . I've just tried onBeforeGetContent now and it didn't work either :(.

Here's a sandbox where I've placed a video in the components to print. The FunctionalComponentWithHook example waits for the onLoadedData event of the video.

https://codesandbox.io/s/react-to-print-forked-402y0

Thanks for looking into this.

@MatthewHerbst MatthewHerbst changed the title Question: Is there a way to wait for the first frame of a video to load? react-to-print does not wait for videos to load Nov 24, 2021
@MatthewHerbst
Copy link
Owner

Hello. I hope you are having a good holiday. I've had time to experiment with this and have been having a very hard time getting the browser to wait to print until the video is loaded in a state that the print dialog will take the currently loaded frame. However, I have seen that even existing versions of the library will properly show video elements that have a poster attribute. I'm going to keep working on just being able to load the first frame of the video, but I feel like the poster is actually the better solution because the first video frame might not be what you actually want to show as the placeholder.

@MatthewHerbst
Copy link
Owner

The fix for this is published in v2.14.3. Please let me know if you run into any additional issues, and thank you for reporting! Happy holidays

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants