speedtrans/js/player.js

91 lines
2.2 KiB
JavaScript
Raw Normal View History

2015-04-21 14:25:36 +00:00
function Player() {
2016-02-29 12:14:01 +00:00
this.supportsOverlay = false;
2015-04-21 14:25:36 +00:00
}
Player.prototype.init = function(elemID) {
2016-02-29 12:14:01 +00:00
//make overlay settings happy..., add a dummy element
this.player = document.getElementById(elemID);
2015-04-21 14:25:36 +00:00
}
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) {
2016-02-29 12:14:01 +00:00
var currentMs = this.get();
var newMs = currentMs + ms;
this.set(newMs);
}
2015-04-21 14:25:36 +00:00
Player.prototype.seekBack = function(ms) {
2016-02-29 12:14:01 +00:00
var currentMs = this.get();
var newMs = currentMs - ms;
this.set(newMs);
}
2015-04-21 14:25:36 +00:00
function VideoPlayer() {
2016-02-29 12:14:01 +00:00
this.supportsOverlay = true;
this.isPlaying = false;
2015-04-21 14:25:36 +00:00
}
VideoPlayer.prototype = new Player();
VideoPlayer.prototype.init = function(elemID) {
2016-02-29 12:14:01 +00:00
this.player = document.getElementById(elemID);
this.width = $(this.player).attr('width');
this.height = $(this.player).attr('height');
2015-04-21 14:25:36 +00:00
}
VideoPlayer.prototype.volUp = function() {
2016-02-29 12:14:01 +00:00
var vol = this.player.volume;
if (vol <= 0.9) { var newVol = vol + 0.1 } else { return false; }
this.player.volume = newVol;
return true;
}
2015-04-21 14:25:36 +00:00
VideoPlayer.prototype.volDown = function() {
2016-02-29 12:14:01 +00:00
var vol = this.player.volume;
if (vol >= 0.1) { var newVol = vol - 0.1 } else { return false; }
this.player.volume = newVol;
return true;
}
2015-04-21 14:25:36 +00:00
VideoPlayer.prototype.set = function(pos) {
2016-02-29 12:14:01 +00:00
this.player.currentTime = pos;
2015-04-21 14:25:36 +00:00
}
VideoPlayer.prototype.get = function() {
2016-02-29 12:14:01 +00:00
try {
return this.player.currentTime;
} catch(err) { }
return -1;
2015-04-21 14:25:36 +00:00
}
VideoPlayer.prototype.play = function() {
2016-02-29 12:14:01 +00:00
this.isPlaying = true;
this.player.play();
2015-04-21 14:25:36 +00:00
}
VideoPlayer.prototype.pause = function() {
2016-02-29 12:14:01 +00:00
this.isPlaying = false;
this.player.pause();
2015-04-21 14:25:36 +00:00
}
VideoPlayer.prototype.togglePause = function() {
2016-02-29 12:14:01 +00:00
if (Video.isPlaying == true) {
Video.pause();
2015-04-21 14:25:36 +00:00
} else {
2016-02-29 12:14:01 +00:00
Video.play();
2015-04-21 14:25:36 +00:00
}
2016-02-29 12:14:01 +00:00
}
2015-04-21 14:25:36 +00:00
VideoPlayer.prototype.listener = function() {
2016-02-29 12:14:01 +00:00
$('#timeCode').html(Ox.formatDuration(Video.get(), 3));
2016-02-29 11:56:25 +00:00
}
2015-04-21 14:25:36 +00:00
VideoPlayer.prototype.setDuration = function(duration) {
2016-02-29 12:14:01 +00:00
this.duration = duration;
2016-02-29 11:56:25 +00:00
}