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() { function setPositionMarker() {
Ox.print(self.interfaceLeft + Math.round(
self.options.position * self.imageWidth / self.options.duration
));
self.$positionMarker.css({ self.$positionMarker.css({
left: self.interfaceLeft + Math.round( left: self.interfaceLeft + Math.round(
self.options.position * self.imageWidth / self.options.duration self.options.position * self.imageWidth / self.options.duration

View file

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