This commit is contained in:
j 2016-02-29 17:44:01 +05:30
parent 17a74231aa
commit 030aaeb910

View file

@ -1,9 +1,9 @@
function Player() { function Player() {
this.supportsOverlay = false; this.supportsOverlay = false;
} }
Player.prototype.init = function(elemID) { Player.prototype.init = function(elemID) {
//make overlay settings happy..., add a dummy element //make overlay settings happy..., add a dummy element
this.player = document.getElementById(elemID); this.player = document.getElementById(elemID);
} }
Player.prototype.play = function() { } Player.prototype.play = function() { }
Player.prototype.pause = function() { } Player.prototype.pause = function() { }
@ -13,78 +13,78 @@ Player.prototype.set = function(pos) { }
Player.prototype.volUp = function() { } Player.prototype.volUp = function() { }
Player.prototype.volDown = function() { } Player.prototype.volDown = function() { }
Player.prototype.seekFwd = function(ms) { Player.prototype.seekFwd = function(ms) {
var currentMs = this.get(); var currentMs = this.get();
var newMs = currentMs + ms; var newMs = currentMs + ms;
this.set(newMs); this.set(newMs);
} }
Player.prototype.seekBack = function(ms) { Player.prototype.seekBack = function(ms) {
var currentMs = this.get(); var currentMs = this.get();
var newMs = currentMs - ms; var newMs = currentMs - ms;
this.set(newMs); this.set(newMs);
} }
function VideoPlayer() { function VideoPlayer() {
this.supportsOverlay = true; this.supportsOverlay = true;
this.isPlaying = false; this.isPlaying = false;
} }
VideoPlayer.prototype = new Player(); VideoPlayer.prototype = new Player();
VideoPlayer.prototype.init = function(elemID) { VideoPlayer.prototype.init = function(elemID) {
this.player = document.getElementById(elemID); this.player = document.getElementById(elemID);
this.width = $(this.player).attr('width'); this.width = $(this.player).attr('width');
this.height = $(this.player).attr('height'); this.height = $(this.player).attr('height');
} }
VideoPlayer.prototype.volUp = function() { VideoPlayer.prototype.volUp = function() {
var vol = this.player.volume; var vol = this.player.volume;
if (vol <= 0.9) { var newVol = vol + 0.1 } else { return false; } if (vol <= 0.9) { var newVol = vol + 0.1 } else { return false; }
this.player.volume = newVol; this.player.volume = newVol;
return true; return true;
} }
VideoPlayer.prototype.volDown = function() { VideoPlayer.prototype.volDown = function() {
var vol = this.player.volume; var vol = this.player.volume;
if (vol >= 0.1) { var newVol = vol - 0.1 } else { return false; } if (vol >= 0.1) { var newVol = vol - 0.1 } else { return false; }
this.player.volume = newVol; this.player.volume = newVol;
return true; return true;
} }
VideoPlayer.prototype.set = function(pos) { VideoPlayer.prototype.set = function(pos) {
this.player.currentTime = pos; this.player.currentTime = pos;
} }
VideoPlayer.prototype.get = function() { VideoPlayer.prototype.get = function() {
try { try {
return this.player.currentTime; return this.player.currentTime;
} catch(err) { } } catch(err) { }
return -1; return -1;
} }
VideoPlayer.prototype.play = function() { VideoPlayer.prototype.play = function() {
this.isPlaying = true; this.isPlaying = true;
this.player.play(); this.player.play();
} }
VideoPlayer.prototype.pause = function() { VideoPlayer.prototype.pause = function() {
this.isPlaying = false; this.isPlaying = false;
this.player.pause(); this.player.pause();
} }
VideoPlayer.prototype.togglePause = function() { VideoPlayer.prototype.togglePause = function() {
if (Video.isPlaying == true) { if (Video.isPlaying == true) {
Video.pause(); Video.pause();
} else { } else {
Video.play(); Video.play();
} }
} }
VideoPlayer.prototype.listener = function() { VideoPlayer.prototype.listener = function() {
$('#timeCode').html(Ox.formatDuration(Video.get(), 3)); $('#timeCode').html(Ox.formatDuration(Video.get(), 3));
} }
VideoPlayer.prototype.setDuration = function(duration) { VideoPlayer.prototype.setDuration = function(duration) {
this.duration = duration; this.duration = duration;
} }