Jump to content
Search Community

Using timeline to play and pause video on hover

EmGes test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

I'm trying to set up un html page displaying 2 videos that could each be played by hovering a button placed next to it. I would also like them to pause on mouse out.

I've tried several codes including using javascript and/or jquery but it just doesn't work.

I'm not sure if it's possible at all so here's my html :

 

<div class="video-one">
<video  loop preload="auto" >
<source src="street-copy.mp4" type="video/mp4">
</video>                                    
</div>  

 

Thank you !

Link to comment
Share on other sites

Hi !

 

Thank you for your answer, I thought that maybe gsap could help achieve this in a simple way. However in the html in your codepen, a div is not closed in the end :

 

 <div id="hover" class="button">PLAY/PAUSE (hover)</div

 

it still works though. When trying that code I had to close it but nothing moves...

Link to comment
Share on other sites

34 minutes ago, EmGes said:

Hi !

 

Thank you for your answer, I thought that maybe gsap could help achieve this in a simple way. However in the html in your codepen, a div is not closed in the end :

 


 <div id="hover" class="button">PLAY/PAUSE (hover)</div

 

it still works though. When trying that code I had to close it but nothing moves...

 

Good catch on the incomplete closing </div> ... that's what I get for typing too fast ;) 

 

play(), pause(), currentTime() are native to JS in the video and audio APIs, so there's not much any framework can/would do to make that easier. I went with jQuery only to make the bindings a bit easier ... but vanilla JS would work just as well.

 

Is there something beyond play/pause that you're hoping GSAP would facilitate?

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...