Skip to content

Commit

Permalink
Improve timing by waiting for the video to start playing
Browse files Browse the repository at this point in the history
  • Loading branch information
1j01 committed Apr 8, 2018
1 parent 7243baf commit a578d1d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions programs/jspaint/src/vaporwave-fun.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ var start_movie = function () {
transition: "opacity 1s ease",
opacity: "0",
});
// TODO: sync time with video, i.e. if you pause it pause this timer
setTimeout(function(){
$(rotologo).css({opacity: 1});
// }, 3000);
}, 15000);

var animate = function () {
var rAF_ID = requestAnimationFrame(animate);
Expand Down Expand Up @@ -128,6 +123,12 @@ var start_movie = function () {

// The API calls this function when the player's state changes.
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING) {
// TODO: pause and resume this timer with the video
setTimeout(function(){
$(rotologo).css({opacity: 1});
}, 14150);
}
if (event.data == YT.PlayerState.ENDED) {
player.destroy();
// TODO: fade to white instead of black, to work with the multiply effect
Expand Down

0 comments on commit a578d1d

Please sign in to comment.