Created
September 8, 2015 11:53
-
-
Save mplatts/01ba1ecabca668efc30b to your computer and use it in GitHub Desktop.
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
// Usage: | |
// | |
// var video = videojs('video_id'); | |
// video.iframeSeek(); | |
// | |
// To start the player at 30s | |
// $iframe[0].contentWindow.postMessage('startTime:30', '*') | |
// | |
(function(window, videojs) { | |
'use strict'; | |
var plugin = function(options) { | |
var player = this; | |
window.addEventListener("message", function(evt) { | |
var msg = evt.data | |
if (msg.match(/^(.*)\:/)[1] == "startTime") { | |
var seek = parseInt(msg.match(/\:(.*)/)[1]); | |
if (seek) { | |
player.ready(function(){ | |
player.currentTime(seek); | |
}); | |
} | |
} | |
}); | |
}; | |
// register the plugin | |
videojs.plugin('iframeSeek', plugin); | |
})(window, window.videojs); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment