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

YouTube video won't stop playing when the lightbox is closed #125

Open
janosrusiczki opened this issue Mar 7, 2021 · 3 comments
Open

YouTube video won't stop playing when the lightbox is closed #125

janosrusiczki opened this issue Mar 7, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@janosrusiczki
Copy link
Contributor

No description provided.

@janosrusiczki janosrusiczki added the bug Something isn't working label Mar 7, 2021
@MagnusJohansson
Copy link

Any updates on this?
It's annoying, and it's blocking me from using this component.

@janosrusiczki
Copy link
Contributor Author

janosrusiczki commented Aug 28, 2021

No updates, from what I investigated I either have to switch to embedding by the YouTube API and send a pause command when the light box is closed OR I have to remove the element containing the YouTube embed when the light box is closed.

@AlexMeuer
Copy link

AlexMeuer commented Oct 14, 2021

We can work around this issue for now by using a key to force the lightbox to rebuild.

<LightBox
        ref="lightbox"
        :key="lbKey"
        :show-thumbs="false"
        :show-light-box="false"
        :media="media"
        @onOpened="onLightboxOpened()"
        @onClosed="onLightboxClosed()"
      ></LightBox>
data: () => ({
    lbKey: 0,
    lbOpen: false,
    media: [ ... ],
},
methods: {
    showVideo() {
      this.$refs.lightbox.showImage(0);
    },
    onLightboxOpened() {
      this.lbOpen = true;
    },
    onLightboxClosed() {
      if (!this.lbOpen) return;
      this.lbOpen = false;
      this.lbKey++;
    },
},

Keeping track of whether the lightbox is open is important, because the relevant onOpened/onClosed event is emitted immediately when the component is built (and we want to avoid infinite loops).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants