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

Allow videos to autoplay, looped, muted without controls #256

Open
ZaDarkSide opened this issue Oct 4, 2020 · 2 comments
Open

Allow videos to autoplay, looped, muted without controls #256

ZaDarkSide opened this issue Oct 4, 2020 · 2 comments

Comments

@ZaDarkSide
Copy link

Is there any options to start videos by default muted, looped without controls?

Basically I have a gallery with images and videos intermingled, for a better user experience I would want to auto play looped and muted the videos and spare the user from a extra click, also there should be no pause/stop button for the video so you can only show the usual prev, next buttons only and no ui for the video player itself.

Is there any way I can accomplish this with this library?

@blueimp
Copy link
Owner

blueimp commented Oct 9, 2020

Hi @ZaDarkSide,

you can make use of the onslideend callback to automatically start playing muted videos:

blueimp.Gallery(
  [
    // ...
  ],
  {
    // ...
    onslideend: function (index, slide) {
      var video = slide.querySelector('video')
      if (video) {
        video.muted = true
        video.autoplay = true
      }
      slide.querySelector('.video-play').click()
    }
  }
)

This works for both HTML5 and YouTube/Vimeo videos, but the latter cannot be the first one in the list.

It still requires pausing videos to go to the next/previous slide and it also does not loop them automatically.

If you wanna implement this on top of this library, maybe your best bet is to implement a separate factory for it:
https://github.com/blueimp/Gallery#additional-content-types

@ZaDarkSide
Copy link
Author

Yeah it's best to be implemented this inside the library, i will take a shot on it with a pull request.

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