Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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
You can’t perform that action at this time.