Jump to content
Search Community

Play and Stop a YouTube Video In TimeLineLite Animation

celli 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

Hi,

 

With timelineLite I have created an animation, then I have a YouTube video that will play on autoPlay via iFrame. I would like to then detect when the video has stopped, and fade-out the video iFrame and continue with another animation... Is there a way to do this ?

 

I also wanted to detect when my browser has reached a certain width, similar to a css media query, and pause or stop the video. Is this also possible ?

Link to comment
Share on other sites

Nice answer AncientWarrior .. it got me thinking..

 

Here is JS polyfill that allows you to wrap the YouTube API in an HTML5 Media API wrapper, so that it can be programmed against as if it was true HTML5 <video>.

 

Add the normal files for jQuery MediaElement.js.

<script src="jquery.js"></script>
<script src="mediaelement-and-player.min.js"></script>
<link rel="stylesheet" href="mediaelementplayer.css" />

::

Add the YouTube video as a <source>

<video width="640" height="360" id="player1" preload="none">
	<source type="video/youtube" src="http://www.youtube.com/watch?v=nOEw9iiopwI" />
</video>

:

Then you can control the <video> using the HTML5 video API with MediaElements

 

Resource:

http://mediaelementjs.com/examples/?name=youtube

 

I hope this helps

  • Like 4
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...