fix muted state on load

This commit is contained in:
j 2021-08-04 14:42:10 +02:00
parent fa93686845
commit f4cafdfd7e
2 changed files with 9 additions and 4 deletions

View file

@ -31,6 +31,7 @@ Ox.VideoElement = function(options, self) {
.defaults({ .defaults({
autoplay: false, autoplay: false,
loop: false, loop: false,
muted: false,
playbackRate: 1, playbackRate: 1,
items: [], items: [],
volume: 1 volume: 1
@ -103,6 +104,7 @@ Ox.VideoElement = function(options, self) {
self.$video = self.$videos[self.currentVideo]; self.$video = self.$videos[self.currentVideo];
self.video = self.$video[0]; self.video = self.$video[0];
self.volume = self.options.volume; self.volume = self.options.volume;
self.muted = self.options.muted;
self.$brightness = $('<div>').css({ self.$brightness = $('<div>').css({
width: '100%', width: '100%',
height: '100%', height: '100%',
@ -332,7 +334,7 @@ Ox.VideoElement = function(options, self) {
function setCurrentVideo(callback) { function setCurrentVideo(callback) {
var css = {}, var css = {},
muted = false, muted = self.muted,
item = self.items[self.currentItem], item = self.items[self.currentItem],
next; next;
Ox.Log('Video', 'sCV', item); Ox.Log('Video', 'sCV', item);
@ -344,7 +346,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();
muted = self.video.muted;
} }
self.currentVideo = Ox.mod(self.currentVideo + 1, self.$videos.length); self.currentVideo = Ox.mod(self.currentVideo + 1, self.$videos.length);
self.$video = self.$videos[self.currentVideo]; self.$video = self.$videos[self.currentVideo];
@ -531,8 +532,11 @@ Ox.VideoElement = function(options, self) {
/*@ /*@
muted <f> get/set muted muted <f> get/set muted
@*/ @*/
that.muted = function() { that.muted = function(value) {
return getset('muted', arguments[0]); if (!Ox.isUndefined(value)) {
self.muted = value;
}
return getset('muted', value);
}; };
/*@ /*@

View file

@ -444,6 +444,7 @@ Ox.VideoPlayer = function(options, self) {
self.$video = Ox.VideoElement({ self.$video = Ox.VideoElement({
items: self.video, items: self.video,
loop: self.options.loop, loop: self.options.loop,
muted: self.options.muted,
playbackRate: self.options.playbackRate, playbackRate: self.options.playbackRate,
volume: self.options.volume volume: self.options.volume
}) })