Skip to content

Instantly share code, notes, and snippets.

@joshuaswilcox
Last active December 26, 2015 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshuaswilcox/7086528 to your computer and use it in GitHub Desktop.
Save joshuaswilcox/7086528 to your computer and use it in GitHub Desktop.
//This is the video player object
//<video id="video-mp4" class="video-js vjs-default-skin"
// controls preload="auto" width="100%" height="350"
// data-setup='{}'
// poster="http://video-js.zencoder.com/oceans-clip.png">
// <source src="http://localhost:3000/assets/barcode64408.mp4" type='video/mp4' />
// </video>
$(function() {
var player = videojs('video-mp4');
player.ready(function() {
if($('.datastream-video,.datastream-audio').length > 0 && $('.datastream-transcript').length > 0) {
//select all timecode-enabled elements
$('*[data-timecodebegin]').attr('data-timecode', true);
$('*[data-timecodeend]').attr('data-timecode', true);
smil_elements = $('*[data-timecode]');
//sync the transcript with the media
smil_elements.each(function() {
$('<a class="sync">[sync]</a>').prependTo($(this)).bind('click', function() {
//This correctly logs the time in seconds to jump to
console.log($(this).parent().data('begin_seconds'))
//This logs the video player to the console, but doesn't change the video time
player.currentTime($(this).parent().data('begin_seconds'));
});
});
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment