Created
October 4, 2012 14:42
-
-
Save vzaar/3833958 to your computer and use it in GitHub Desktop.
vzaar bookmarks
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
<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&colourSet=grey&colourBg=#ffffff&border=none&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 = " " + 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 = " " + 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