annotate johndyer-mediaelement-13fa20a/src/js/mep-feature-time.js @ 25:4a4bd554b4c1 tip

Closing this sub branch.
author Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk>
date Mon, 25 Mar 2013 14:02:54 +0000
parents 032bc65ebafc
children
rev   line source
gyorgy@0 1 (function($) {
gyorgy@0 2 // current and duration 00:00 / 00:00
gyorgy@0 3 MediaElementPlayer.prototype.buildcurrent = function(player, controls, layers, media) {
gyorgy@0 4 var t = this;
gyorgy@0 5
gyorgy@0 6 $('<div class="mejs-time">'+
gyorgy@0 7 '<span class="mejs-currenttime">' + (player.options.alwaysShowHours ? '00:' : '') + '00:00</span>'+
gyorgy@0 8 '</div>')
gyorgy@0 9 .appendTo(controls);
gyorgy@0 10
gyorgy@0 11 t.currenttime = t.controls.find('.mejs-currenttime');
gyorgy@0 12
gyorgy@0 13 media.addEventListener('timeupdate',function() {
gyorgy@0 14 player.updateCurrent();
gyorgy@0 15 }, false);
gyorgy@0 16 };
gyorgy@0 17
gyorgy@0 18 MediaElementPlayer.prototype.buildduration = function(player, controls, layers, media) {
gyorgy@0 19 var t = this;
gyorgy@0 20
gyorgy@0 21 if (controls.children().last().find('.mejs-currenttime').length > 0) {
gyorgy@0 22 $(' <span> | </span> '+
gyorgy@0 23 '<span class="mejs-duration">' + (player.options.alwaysShowHours ? '00:' : '') + '00:00</span>')
gyorgy@0 24 .appendTo(controls.find('.mejs-time'));
gyorgy@0 25 } else {
gyorgy@0 26
gyorgy@0 27 // add class to current time
gyorgy@0 28 controls.find('.mejs-currenttime').parent().addClass('mejs-currenttime-container');
gyorgy@0 29
gyorgy@0 30 $('<div class="mejs-time mejs-duration-container">'+
gyorgy@0 31 '<span class="mejs-duration">' + (player.options.alwaysShowHours ? '00:' : '') + '00:00</span>'+
gyorgy@0 32 '</div>')
gyorgy@0 33 .appendTo(controls);
gyorgy@0 34 }
gyorgy@0 35
gyorgy@0 36 t.durationD = t.controls.find('.mejs-duration');
gyorgy@0 37
gyorgy@0 38 media.addEventListener('timeupdate',function() {
gyorgy@0 39 player.updateDuration();
gyorgy@0 40 }, false);
gyorgy@0 41 };
gyorgy@0 42
gyorgy@0 43 MediaElementPlayer.prototype.updateCurrent = function() {
gyorgy@0 44 var t = this;
gyorgy@0 45
gyorgy@0 46 if (t.currenttime) {
gyorgy@0 47 t.currenttime.html(mejs.Utility.secondsToTimeCode(t.media.currentTime | 0, t.options.alwaysShowHours || t.media.duration > 3600 ));
gyorgy@0 48 }
gyorgy@0 49 }
gyorgy@0 50 MediaElementPlayer.prototype.updateDuration = function() {
gyorgy@0 51 var t = this;
gyorgy@0 52
gyorgy@0 53 if (t.media.duration && t.durationD) {
gyorgy@0 54 t.durationD.html(mejs.Utility.secondsToTimeCode(t.media.duration, t.options.alwaysShowHours));
gyorgy@0 55 }
gyorgy@0 56 };
gyorgy@0 57
gyorgy@0 58 })(mejs.$);