support per clip volume

This commit is contained in:
j 2017-04-15 13:45:01 +02:00
parent 34cdae0ab3
commit bfb5c3d3ef
6 changed files with 78 additions and 18 deletions

View file

@ -175,6 +175,21 @@ Ox.ClipPanel = function(options, self) {
visible: true, visible: true,
width: 90 width: 90
}, },
{
align: 'right',
editable: self.options.editable,
format: function(value, data) {
return Ox.formatNumber(value, 2);
},
id: 'volume',
operator: '+',
sort: function(value, data) {
return data.sort;
},
title: Ox._('Volume'),
visible: false,
width: 45
},
{ {
addable: false, addable: false,
id: 'sort', id: 'sort',
@ -491,6 +506,16 @@ Ox.ClipPanel = function(options, self) {
}, },
submit: function(data) { submit: function(data) {
var value = self.$list.value(data.id); var value = self.$list.value(data.id);
if (data.key == 'volume') {
data.value = parseFloat(data.value);
if (data.value >= 1 || Ox.isNaN(data.value)) {
data.value = 1;
} else if (data.value < 0) {
data.value = 0;
}
self.$list.value(data.id, data.key, data.value);
that.triggerEvent('edit', data);
} else {
data.value = Ox.parseDuration(data.value); data.value = Ox.parseDuration(data.value);
if ( if (
(data.key == 'in' && data.value < value.out) (data.key == 'in' && data.value < value.out)
@ -510,6 +535,7 @@ Ox.ClipPanel = function(options, self) {
self.$list.value(data.id, data.key, value[data.key]); self.$list.value(data.id, data.key, value[data.key]);
} }
} }
}
}); });
return $list; return $list;
} }

View file

@ -147,6 +147,11 @@ Ox.VideoAnnotationPanel = function(options, self) {
self.$menuButton.checkItem('timelines_' + self.options.timeline); self.$menuButton.checkItem('timelines_' + self.options.timeline);
updateTimelines(); updateTimelines();
}, },
volume: function() {
self.$player[0].options({
volume: self.options.volume
});
},
width: setSizes width: setSizes
}) })
.bindEvent({ .bindEvent({

View file

@ -140,6 +140,11 @@ Ox.VideoEditPanel = function(options, self) {
cuts: self.cuts cuts: self.cuts
}); });
}, },
volume: function() {
self.$video.options({
volume: self.options.volume
});
},
width: function() { width: function() {
self.$video.options({width: getPlayerWidth()}); self.$video.options({width: getPlayerWidth()});
self.$timeline.options({width: getTimelineWidth()}); self.$timeline.options({width: getTimelineWidth()});

View file

@ -101,6 +101,7 @@ Ox.VideoElement = function(options, self) {
self.$videos = [getVideo(), getVideo()]; self.$videos = [getVideo(), getVideo()];
self.$video = self.$videos[self.currentVideo]; self.$video = self.$videos[self.currentVideo];
self.video = self.$video[0]; self.video = self.$video[0];
self.volume = 1;
self.$brightness = $('<div>').css({ self.$brightness = $('<div>').css({
width: '100%', width: '100%',
height: '100%', height: '100%',
@ -204,6 +205,15 @@ Ox.VideoElement = function(options, self) {
return $(video); return $(video);
}; };
function getVolume() {
var volume = 1;
if (self.items[self.currentItem] && Ox.isNumber(self.items[self.currentItem].volume)) {
volume = self.items[self.currentItem].volume;
}
return self.volume * volume;
}
function isReady($video, callback) { function isReady($video, callback) {
if ($video[0].seeking) { if ($video[0].seeking) {
that.triggerEvent('seeking'); that.triggerEvent('seeking');
@ -320,7 +330,6 @@ Ox.VideoElement = function(options, self) {
function setCurrentVideo(callback) { function setCurrentVideo(callback) {
var css = {}, var css = {},
muted = false, muted = false,
volume = 1,
item = self.items[self.currentItem], item = self.items[self.currentItem],
next; next;
Ox.Log('Video', 'sCV', item); Ox.Log('Video', 'sCV', item);
@ -332,7 +341,6 @@ Ox.VideoElement = function(options, self) {
if (self.video) { if (self.video) {
self.$videos[self.currentVideo].hide(); self.$videos[self.currentVideo].hide();
self.video.pause(); self.video.pause();
volume = self.video.volume;
muted = self.video.muted; muted = self.video.muted;
} }
self.currentVideo = Ox.mod(self.currentVideo + 1, self.$videos.length); self.currentVideo = Ox.mod(self.currentVideo + 1, self.$videos.length);
@ -343,7 +351,7 @@ Ox.VideoElement = function(options, self) {
self.video.src = item.src; self.video.src = item.src;
self.video.preload = 'auto'; self.video.preload = 'auto';
} }
self.video.volume = volume; self.video.volume = getVolume();
self.video.muted = muted; self.video.muted = muted;
self.video.playbackRate = self.options.playbackRate; self.video.playbackRate = self.options.playbackRate;
self.$video.css(css); self.$video.css(css);
@ -557,7 +565,13 @@ Ox.VideoElement = function(options, self) {
volume <f> get/set volume volume <f> get/set volume
@*/ @*/
that.volume = function(value) { that.volume = function(value) {
return getset('volume', arguments[0]); if (Ox.isUndefined(value)) {
value = self.volume
} else {
self.volume = value;
self.video.volume = getVolume());
}
return value;
}; };
return that; return that;

View file

@ -123,6 +123,11 @@ Ox.VideoPlayerPanel = function(options, self) {
timeline: function() { timeline: function() {
self.$timeline.options({type: self.options.timeline}); self.$timeline.options({type: self.options.timeline});
}, },
volume: function() {
self.$video.options({
volume: self.options.volume
});
},
width: function() { width: function() {
self.$video.options({width: getPlayerWidth()}); self.$video.options({width: getPlayerWidth()});
self.$timeline.options({width: getTimelineWidth()}); self.$timeline.options({width: getTimelineWidth()});

View file

@ -57,6 +57,11 @@ Ox.VideoTimelinePlayer = function(options, self) {
self.$menuButton.checkItem('timelines_' + self.options.timeline); self.$menuButton.checkItem('timelines_' + self.options.timeline);
updateTimeline(); updateTimeline();
}, },
volume: function() {
self.$video.options({
volume: self.options.volume
});
},
width: setWidth width: setWidth
}); });