Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
vzaar bookmarks
<div id='video-container'>
<div class='vzaar_media_player'>
<object data='http://view.vzaar.com/1080935/flashplayer' height='324'
id='video' type='application/x-shockwave-flash' width='576'>
<param name='allowFullScreen' value='true' />
<param name='allowScriptAccess' value='always' />
<param name='wmode' value='transparent' />
<param name='movie' value='http://view.vzaar.com/1080935/flashplayer' />
<param name='flashvars' value='apiOn=true&amp;colourSet=grey&amp;colourBg=#ffffff&amp;border=none&amp;socialSharing=0,0,0' />
<video controls='' height='324' id='vzvid' onclick='this.play();' poster='http://view.vzaar.com/1080935/image'
preload='none' src='http://view.vzaar.com/1080935/video' width='576'></video>
</object>
</div>
<div id='vid-info' style="font-family: Courier, monospace; font-size: 13px;">
<a href='#' id='addBookmark'>Add Bookmark</a> | <a href='#' id='resetBookmark'>Reset Bookmark</a>
</div>
</div>
<script src='path/to/javascripts/jquery.cookie.js'></script>
<script type='text/javascript'>
//<![CDATA[
function vzaarPlayerReady() {
vzPlayer = document.getElementById("video");
vzPlayer.addEventListener("playState", "statusCheck");
}
function statusCheck(state) {
if (state == 'mediaStarted') {
vzPlayer.seekTo($.cookie('bookmark'));
}
}
function timeConvert(curTime) {
if (isNaN(curTime) == true) {
curTime = 0;
}
mins = ("0" + Math.floor(curTime / 60)).slice(-2);
secs = ("0" + curTime % 60).slice(-2);
return mins + ":" + secs;
}
$(document).ready(function () {
if ($.cookie('bookmark') == null) {
seconds = 0;
} else {
seconds = $.cookie('bookmark').toString();
}
if (seconds.length == 1) {
seconds = "&nbsp;" + seconds;
}
$('#vid-info').append('<span id="cur-bookmark"> | Current bookmark: ' + timeConvert(seconds) + '</span>');
function addBookmark(seconds) {
$.cookie('bookmark', seconds, {
expires: 1
});
seconds = seconds.toString();
if (seconds.length == 1) {
seconds = "&nbsp;" + seconds;
}
$('#cur-bookmark').html(' | Current bookmark: ' + timeConvert(seconds));
}
$("#addBookmark").click(function () {
curTime = Math.round(vzPlayer.getTime());
if (isNaN(curTime) == true) {
curTime = 0;
}
addBookmark(curTime);
})
$("#resetBookmark").click(function () {
$.cookie('bookmark', 0);
addBookmark(0);
})
});
//]]>
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment