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

How to add loading indicator when video is loading? #182

Closed
bennik88 opened this issue Mar 10, 2022 · 3 comments
Closed

How to add loading indicator when video is loading? #182

bennik88 opened this issue Mar 10, 2022 · 3 comments

Comments

@bennik88
Copy link

bennik88 commented Mar 10, 2022

Problem
I want to show a loading indicator as long as the video is loading.
Is there any workaround for now?

What I've tried but for sure can't work because of the architecture:

 {loading ? (
          <div
            style={{
              width: 210 * scaleImageFactor,
              height: 90 * scaleImageFactor,
            }}
          >
            ... Loading
          </div>
        ) : (
          <Vimeo
            video={project.vimeoId}
            width={210 * scaleImageFactor}
            height={90 * scaleImageFactor}
            responsive={true}
            onLoaded={() => setLoading(false)}
          />
        )}

Potential Solution
A prop like loadingOverlay={<div><p>...loading</p></<div> which accepts an JSX.Element as a loading placeholder for the video.

@goto-bus-stop
Copy link
Member

the vimeo element must be in the DOM for the video to load. Your approach can probably work, if you keep the vimeo component mounted unconditionally:

    <>
       {loading ? (
          <div
            style={{
              width: 210 * scaleImageFactor,
              height: 90 * scaleImageFactor,
            }}
          >
            ... Loading
          </div>
        ) : null}
        <Vimeo
          video={project.vimeoId}
          width={210 * scaleImageFactor}
          height={90 * scaleImageFactor}
          responsive={true}
          onLoaded={() => setLoading(false)}
        />
    </>

Then you can use CSS to put your loading overlay on top of the video. you would need to call setLoading(true) yourself whenever you change the video ID.

@bennik88
Copy link
Author

I see what you want to achieve. So you're saying there was no thought involved yet to show a loading screen as long as the video is loading? As I'm seeing big layout changes when the video is loaded as there is no placeholder meanwhile. *Thank you for your fast answer!

@goto-bus-stop
Copy link
Member

goto-bus-stop commented Mar 29, 2022

So you're saying there was no thought involved yet to show a loading screen as long as the video is loading?

well, I did think about it and concluded that this library should not have that functionality. but it should provide the events necessary so you can implement it yourself, and my previous reply is just a suggestion of how you might achieve it. If more events are needed that are provided by the vimeo SDK then the library should provide access to those.

@goto-bus-stop goto-bus-stop closed this as not planned Won't fix, can't repro, duplicate, stale Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants