Skip to content

Instantly share code, notes, and snippets.

@rohit-skywalker
Created May 17, 2017 11:42
Show Gist options
  • Save rohit-skywalker/256ec727940a8eccdf436e3f448b45e2 to your computer and use it in GitHub Desktop.
Save rohit-skywalker/256ec727940a8eccdf436e3f448b45e2 to your computer and use it in GitHub Desktop.
<script>
jQuery(document).ready(function($){
$('.unit_content').find('audio,video').each(function(){
if(typeof this.player !== "undefined"){
if(!$('#mark-complete').hasClass('tip')){return;}
var _player = this.player;
old = _player.media.setCurrentTime;
_player.media.setCurrentTime = function(time) {
if(time <= this.currentTime){
old.apply(this,[time]);
}
};
}
});
$(document).on('media_loaded','#mark-complete',function(){
$('.unit_content').find('audio,video').each(function(){
if(typeof this.player !== "undefined"){
if(!$('#mark-complete').hasClass('tip')){return;}
var _player = this.player;
old = _player.media.setCurrentTime;
_player.media.setCurrentTime = function(time) {
if(time <= this.currentTime){
old.apply(this,[time]);
}
};
}
});
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment