init
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
define([], function () {
|
||||
'use strict';
|
||||
|
||||
return function (Widget) {
|
||||
var originalCreateVideoData = Widget.prototype._createVideoData;
|
||||
|
||||
Widget.prototype._createVideoData = function (inputData, isJSON) {
|
||||
var videoData = [], item, url, i;
|
||||
if (isJSON) {
|
||||
inputData = JSON.parse(inputData);
|
||||
}
|
||||
for (i = 0; i < inputData.length; i++) {
|
||||
item = inputData[i];
|
||||
url = item.videoUrl || '';
|
||||
if (item.mediaType !== 'external-video') {
|
||||
videoData.push({mediaType: item.mediaType, isBase: item.isBase, id: '', provider: ''});
|
||||
} else if (/\.mp4(?:$|\?)/i.test(url) || item.provider === 'html5') {
|
||||
videoData.push({
|
||||
mediaType: 'video',
|
||||
isBase: item.isBase,
|
||||
id: url,
|
||||
provider: 'html5',
|
||||
videoUrl: url,
|
||||
useYoutubeNocookie: false
|
||||
});
|
||||
} else {
|
||||
videoData.push(originalCreateVideoData.call(this, [item], false)[0]);
|
||||
}
|
||||
}
|
||||
return videoData;
|
||||
};
|
||||
return Widget;
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,34 @@
|
||||
define(['jquery'], function ($) {
|
||||
'use strict';
|
||||
|
||||
return function (Widget) {
|
||||
Widget = Widget || ($.mage && $.mage.productVideoLoader);
|
||||
|
||||
if (!Widget || !Widget.prototype || Widget.prototype._esunHtml5VideoPatched) {
|
||||
return Widget;
|
||||
}
|
||||
|
||||
var originalCreate = Widget.prototype._create;
|
||||
Widget.prototype._esunHtml5VideoPatched = true;
|
||||
|
||||
Widget.prototype._create = function () {
|
||||
var video;
|
||||
if (this.element.data('type') !== 'html5') {
|
||||
return originalCreate.apply(this, arguments);
|
||||
}
|
||||
video = $('<video controls autoplay playsinline></video>').attr('src', this.element.data('code'));
|
||||
if (this.element.data('loop')) {
|
||||
video.attr('loop', 'loop');
|
||||
}
|
||||
this.element.empty().append(video).addClass('responsive');
|
||||
this.element.closest('.fotorama__stage__frame').addClass('fotorama__product-video--loaded');
|
||||
this._player = {
|
||||
play: function () { video.get(0).play(); },
|
||||
pause: function () { video.get(0).pause(); },
|
||||
stop: function () { video.get(0).pause(); video.get(0).currentTime = 0; },
|
||||
playing: function () { return !video.get(0).paused; }
|
||||
};
|
||||
};
|
||||
return Widget;
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user