Created
March 10, 2016 15:27
-
-
Save Langmans/7b3cffe90468a2d9095e to your computer and use it in GitHub Desktop.
add classes to video / audio DOM elements so you can add custom controls.
This file contains hidden or 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
| jQuery(function($){ | |
| $('audio,video') | |
| .on('init ended pause play playing progress ratechange seeked seeking stalled suspend waiting', function () { | |
| var obj = this, $obj = $(this); | |
| if ($obj.is('.has-custom-controls')) { | |
| $obj.removeAttr('controls'); | |
| } | |
| $.each(['ended', 'error', 'loop', 'muted', 'paused', 'seeking'], function (i, prop) { | |
| try { | |
| var bool = obj[prop]; | |
| //console.log(prop, bool); | |
| $obj.toggleClass('is-' + prop, bool); | |
| $obj.toggleClass('not-' + prop, !bool); | |
| } catch (e) { | |
| console.log(e); | |
| } | |
| }); | |
| }) | |
| .trigger('init'); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment