Last active
July 1, 2016 16:47
-
-
Save grappler/02b9d43c0606d74869a1 to your computer and use it in GitHub Desktop.
Flowplayer speed buttons to switch video speed for https://wordpress.org/plugins/flowplayer5/ v1.11.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// global speed widgets setup applying to all players on page | |
flowplayer(function (api, root) { | |
var speedelement = root.querySelector(".fp5-speed-buttons"), | |
// turn button elements into an indexable array | |
buttons = Array.prototype.slice.call(speedelement.getElementsByTagName("span")); | |
api.on("load", function (e, api) { | |
// remove speed buttons if playback rate changes are not available | |
if (api.engine.engineName == "flash" || !flowplayer.support.inlineVideo) { | |
speedelement.parentNode.removeChild(speedelement); | |
} | |
}).on("speed", function (e, api, rate) { | |
// mark the current speed button as active | |
var i; | |
speedelement.querySelector(".fp5-speed-active").removeAttribute("class"); | |
for (i = 0; i < api.conf.speeds.length; i = i + 1) { | |
if (api.conf.speeds[i] == rate) { | |
buttons[i].className = "fp5-speed-active"; | |
break; | |
} | |
} | |
}); | |
// bind speed() call to click on buttons | |
buttons.forEach(function (button) { | |
button.onclick = function () { | |
var i; | |
if (button.classNme != "fp5-speed-active") { | |
for (i = 0; i < api.conf.speeds.length; i = i + 1) { | |
if (buttons[i] === button) { | |
api.speed(api.conf.speeds[i]); | |
break; | |
} | |
} | |
} | |
}; | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* initially hide speed buttons while they cannot be used */ | |
.is-splash.flowplayer .fp5-speed-buttons, .is-loading.flowplayer .fp5-speed-buttons { | |
display: none; | |
} | |
.flowplayer .fp5-speed-buttons { | |
position: absolute; | |
right: 15px; | |
bottom: 40px; | |
z-index: 12; /* make clickable */ | |
display: block; | |
opacity: 1; | |
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100); | |
} | |
.is-mouseout.flowplayer .fp5-speed-buttons { | |
opacity: 0; | |
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0); | |
/* same transition as other ui elements like fullscreen */ | |
-webkit-transition: opacity .15s .3s; | |
-moz-transition: opacity .15s .3s; | |
transition: opacity .15s .3s; | |
} | |
.flowplayer .fp5-speed-buttons span { | |
padding: 1ex; | |
margin: 0.5ex; | |
width: 3em; | |
display: inline-block; | |
text-align: center; | |
font-weight: bold; | |
background-color: #eee; | |
cursor: pointer; | |
-webkit-border-radius: 1ex; | |
-moz-border-radius: 1ex; | |
border-radius: 1ex; | |
} | |
.flowplayer .fp5-speed-buttons span.fp5-speed-active { | |
color: #00a7c8; | |
background-color: #666; | |
cursor: default; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment