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