keep volume/muted values from current video when changing parts, fixes #200

This commit is contained in:
j 2012-02-16 22:05:30 +05:30
parent d13d0e3d3f
commit f28ed7366b

View file

@ -23,7 +23,7 @@ Ox.VideoElement = function(options, self) {
.options(options || {}) .options(options || {})
.css({width: '100%', height: '100%'}); .css({width: '100%', height: '100%'});
Ox.Log('Video', 'VIDEO ELEMENT OPTIONS', self.options) Ox.Log('Video', 'VIDEO ELEMENT OPTIONS', self.options);
self.items = []; self.items = [];
self.paused = true; self.paused = true;
@ -64,7 +64,7 @@ Ox.VideoElement = function(options, self) {
function getset(key, value) { function getset(key, value) {
var ret; var ret;
if (Ox.isUndefined(value)) { if (Ox.isUndefined(value)) {
ret = self.video[key] ret = self.video[key];
} else { } else {
self.video[key] = value; self.video[key] = value;
ret = that; ret = that;
@ -73,7 +73,7 @@ Ox.VideoElement = function(options, self) {
} }
function loadPage(page, callback) { function loadPage(page, callback) {
Ox.Log('Video', 'VIDEO loadPage', page) Ox.Log('Video', 'VIDEO loadPage', page);
//page = Ox.mod(page, self.numberOfPages); //page = Ox.mod(page, self.numberOfPages);
var loadedmetadata = 0, var loadedmetadata = 0,
start = page * self.pageLength, start = page * self.pageLength,
@ -84,14 +84,14 @@ Ox.VideoElement = function(options, self) {
data.forEach(function(data, i) { data.forEach(function(data, i) {
self.items[start + i] = loadItem(data.parts, data.points, function(item) { self.items[start + i] = loadItem(data.parts, data.points, function(item) {
if (++loadedmetadata == pageLength) { if (++loadedmetadata == pageLength) {
Ox.Log('Video', 'VIDEO page', page, 'loaded') Ox.Log('Video', 'VIDEO page', page, 'loaded');
callback && callback(); callback && callback();
} }
}); });
}); });
}); });
} else { } else {
Ox.Log('Video', 'PAGE IN CACHE') Ox.Log('Video', 'PAGE IN CACHE');
callback && callback(); callback && callback();
} }
} }
@ -236,7 +236,9 @@ Ox.VideoElement = function(options, self) {
function setCurrentPart(part) { function setCurrentPart(part) {
Ox.Log('Video', 'sCP', part); Ox.Log('Video', 'sCP', part);
var css = {}; var css = {},
muted = false,
volume = 1;
['left', 'top', 'width', 'height'].forEach(function(key) { ['left', 'top', 'width', 'height'].forEach(function(key) {
css[key] = self.$video.css(key); css[key] = self.$video.css(key);
}); });
@ -244,12 +246,16 @@ Ox.VideoElement = function(options, self) {
self.$video.hide(); self.$video.hide();
self.video.pause(); self.video.pause();
self.video.currentTime = 0; self.video.currentTime = 0;
volume = self.video.volume;
muted = self.video.muted;
} }
self.$video = self.items[self.currentItem].$videos[part].css(css).show(); self.$video = self.items[self.currentItem].$videos[part].css(css).show();
self.video = self.$video[0]; self.video = self.$video[0];
self.video.volume = volume;
self.video.muted = muted;
!self.paused && self.video.play(); !self.paused && self.video.play();
self.currentPart = part; self.currentPart = part;
Ox.Log('Video', 'sCP', part, self.video.src) Ox.Log('Video', 'sCP', part, self.video.src);
} }
function setCurrentTime(time) { function setCurrentTime(time) {
@ -272,7 +278,7 @@ Ox.VideoElement = function(options, self) {
function unloadPage(page) { function unloadPage(page) {
//page = Ox.mod(page, self.numberOfPages); //page = Ox.mod(page, self.numberOfPages);
Ox.Log('Video', 'unloadPage', page) Ox.Log('Video', 'unloadPage', page);
var start = page * self.pageLength, var start = page * self.pageLength,
stop = Math.min(start + self.pageLength, self.numberOfItems); stop = Math.min(start + self.pageLength, self.numberOfItems);
Ox.range(start, stop).forEach(function(i) { Ox.range(start, stop).forEach(function(i) {
@ -397,7 +403,7 @@ Ox.VideoElement = function(options, self) {
playNext <f> play next playNext <f> play next
@*/ @*/
that.playNext = function() { that.playNext = function() {
Ox.Log('Video', 'PLAY NEXT') Ox.Log('Video', 'PLAY NEXT');
setCurrentItem(self.currentItem + 1); setCurrentItem(self.currentItem + 1);
self.video.play(); self.video.play();
}; };
@ -448,7 +454,7 @@ Ox.VideoElement = function(options, self) {
@*/ @*/
that.volume = function(value) { that.volume = function(value) {
return getset('volume', arguments[0]); return getset('volume', arguments[0]);
} };
return that; return that;