add keyboard controls for volume

This commit is contained in:
rolux 2011-05-17 12:34:55 +02:00
parent 179d1ecb81
commit c7167462e8
2 changed files with 21 additions and 8 deletions

View file

@ -221,9 +221,6 @@ Ox.SmallVideoTimeline = function(options, self) {
}
function setPositionMarker() {
Ox.print(self.interfaceLeft + Math.round(
self.options.position * self.imageWidth / self.options.duration
));
self.$positionMarker.css({
left: self.interfaceLeft + Math.round(
self.options.position * self.imageWidth / self.options.duration

View file

@ -140,9 +140,15 @@ Ox.VideoPlayer = function(options, self) {
if (self.options.enableKeyboard) {
that.bindEvent({
key_0: function() {
toggleMuted(true);
},
key_1: function() {
toggleScale(true);
},
key_equal: function() {
changeVolumeBy(0.1);
},
key_f: function() {
// need timeout so the "f" doesn't appear in the input field
setTimeout(function() {
@ -159,8 +165,8 @@ Ox.VideoPlayer = function(options, self) {
key_left: function() {
setPosition(self.options.position - self.secondsPerFrame, true);
},
key_m: function() {
toggleMuted(true);
key_minus: function() {
changeVolumeBy(-0.1);
},
key_p: function() {
playInToOut();
@ -830,7 +836,9 @@ Ox.VideoPlayer = function(options, self) {
float: 'left'
})
.bindEvent({
change: setVolume
change: function(data) {
setVolume(data.value);
}
})
.appendTo(self.$volume);
@ -1461,8 +1469,16 @@ Ox.VideoPlayer = function(options, self) {
}
}
function setVolume(data) {
self.options.volume = data.value;
function changeVolumeBy(num) {
self.options.volume = Ox.limit(self.options.volume + num, 0, 1);
setVolume(self.options.volume);
self.$volumeInput && self.$volumeInput.options({
value: self.options.volume
});
}
function setVolume(volume) {
self.options.volume = volume;
if (!!self.options.volume == self.options.muted) {
self.options.muted = !self.options.muted;
self.video.muted = self.options.muted;