1var player, 2 time_update_interval = 0; 3 4function onYouTubeIframeAPIReady() { 5 player = new YT.Player('video-placeholder', { 6 width: 600, 7 height: 400, 8 videoId: 'Xa0Q0J5tOP0', 9 playerVars: { 10 color: 'white', 11 playlist: 'taJ60kskkns,FG0fTKAqZ5g' 12 }, 13 events: { 14 onReady: initialize 15 } 16 }); 17} 18 19function initialize(){ 20 21 // Update the controls on load 22 updateTimerDisplay(); 23 updateProgressBar(); 24 25 // Clear any old interval. 26 clearInterval(time_update_interval); 27 28 // Start interval to update elapsed time display and 29 // the elapsed part of the progress bar every second. 30 time_update_interval = setInterval(function () { 31 updateTimerDisplay(); 32 updateProgressBar(); 33 }, 1000); 34 35 36 $('#volume-input').val(Math.round(player.getVolume())); 37} 38 39 40// This function is called by initialize() 41function updateTimerDisplay(){ 42 // Update current time text display. 43 $('#current-time').text(formatTime( player.getCurrentTime() )); 44 $('#duration').text(formatTime( player.getDuration() )); 45} 46 47 48// This function is called by initialize() 49function updateProgressBar(){ 50 // Update the value of our progress bar accordingly. 51 $('#progress-bar').val((player.getCurrentTime() / player.getDuration()) * 100); 52} 53 54 55// Progress bar 56 57$('#progress-bar').on('mouseup touchend', function (e) { 58 59 // Calculate the new time for the video. 60 // new time in seconds = total duration in seconds * ( value of range input / 100 ) 61 var newTime = player.getDuration() * (e.target.value / 100); 62 63 // Skip video to new time. 64 player.seekTo(newTime); 65 66}); 67 68 69// Playback 70 71$('#play').on('click', function () { 72 player.playVideo(); 73}); 74 75 76$('#pause').on('click', function () { 77 player.pauseVideo(); 78}); 79 80 81// Sound volume 82 83 84$('#mute-toggle').on('click', function() { 85 var mute_toggle = $(this); 86 87 if(player.isMuted()){ 88 player.unMute(); 89 mute_toggle.text('volume_up'); 90 } 91 else{ 92 player.mute(); 93 mute_toggle.text('volume_off'); 94 } 95}); 96 97$('#volume-input').on('change', function () { 98 player.setVolume($(this).val()); 99}); 100 101 102// Other options 103 104 105$('#speed').on('change', function () { 106 player.setPlaybackRate($(this).val()); 107}); 108 109$('#quality').on('change', function () { 110 player.setPlaybackQuality($(this).val()); 111}); 112 113 114// Playlist 115 116$('#next').on('click', function () { 117 player.nextVideo() 118}); 119 120$('#prev').on('click', function () { 121 player.previousVideo() 122}); 123 124 125// Load video 126 127$('.thumbnail').on('click', function () { 128 129 var url = $(this).attr('data-video-id'); 130 131 player.cueVideoById(url); 132 133}); 134 135 136// Helper Functions 137 138function formatTime(time){ 139 time = Math.round(time); 140 141 var minutes = Math.floor(time / 60), 142 seconds = time - minutes * 60; 143 144 seconds = seconds < 10 ? '0' + seconds : seconds; 145 146 return minutes + ":" + seconds; 147} 148 149 150$('pre code').each(function(i, block) {
151 hljs.highlightBlock(block); 152});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.