vvvmax / unitegallery

Unite Gallery - Responsive jQuery Image and Video Gallery Plugin. Aim to be the best gallery on the web on it's kind. See demo here:
http://unitegallery.net
MIT License
530 stars 158 forks source link

Add html5 media events to api #193

Open dorthrithil opened 6 years ago

dorthrithil commented 6 years ago

I need to detect video events (play, pause, ended, ...) in my application. As far as I can see from the documentation those events are not forwarded by the api.

Right now I use the following workaround which is necessary as video elements are dynamically inserted by the gallery when you press play:

this.mutationObserver = new MutationObserver((mutations: any) => {
      mutations.forEach(mutation => {
        mutation.addedNodes.forEach(addedNode => {
          if (addedNode.nodeName === 'VIDEO') {
            $(addedNode).on('play', () => {
              // Do something
            });
            // Watch more events
          }
        });
      });
    });
this.mutationObserver.observe(document.body, {childList: true, subtree: true});

This solution works fine, but I think it would be better if you forward the media events via the unitegallery API.

vvvmax commented 6 years ago

Hi. I am a bit bussy right now with my other projects but if you want i can do it for you as a small freelance task. If you interested please write to: vvvmax@gmail.com

On Tue, Aug 7, 2018, 11:54 AM Felix Engelmann notifications@github.com wrote:

I need to detect video events (play, pause, ended, ...) in my application. As far as I can see from the documentation those events are not forwarded by the api.

Right now I use the following workaround which is necessary as video elements are dynamically inserted by the gallery when you press play:

this.mutationObserver = new MutationObserver((mutations: any) => { mutations.forEach(mutation => { mutation.addedNodes.forEach(addedNode => { if (addedNode.nodeName === 'VIDEO') { $(addedNode).on('play', () => { // Do something }); // Watch more events } }); }); }); this.mutationObserver.observe(document.body, {childList: true, subtree: true});

This solution works fine, but I think it would be better if you forward the media events via the unitegallery API.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vvvmax/unitegallery/issues/193, or mute the thread https://github.com/notifications/unsubscribe-auth/AC_K_kfvyNg5bNwI5-ofKDjvnGmYL7vrks5uOVWvgaJpZM4VxwGj .