Add unload funcs to audio and video previews.
This commit is contained in:
parent
e5966bc610
commit
b7f25c45f2
3 changed files with 25 additions and 6 deletions
|
@ -22,16 +22,23 @@ const updateGui = () => {
|
|||
]);
|
||||
};
|
||||
|
||||
const addUnloadFn = el => {
|
||||
el.unload = () => {
|
||||
el.src = '';
|
||||
el.load();
|
||||
};
|
||||
};
|
||||
|
||||
const load = item => {
|
||||
return new Promise(resolve => {
|
||||
const $el = dom(tpl)
|
||||
.on('loadedmetadata', () => resolve($el))
|
||||
.attr('controls', 'controls')
|
||||
.attr('src', item.absHref);
|
||||
|
||||
.attr('controls', 'controls');
|
||||
if (settings.autoplay) {
|
||||
$el.attr('autoplay', 'autoplay');
|
||||
}
|
||||
addUnloadFn($el[0]);
|
||||
$el.attr('src', item.absHref);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -26,16 +26,23 @@ const updateGui = () => {
|
|||
]);
|
||||
};
|
||||
|
||||
const addUnloadFn = el => {
|
||||
el.unload = () => {
|
||||
el.src = '';
|
||||
el.load();
|
||||
};
|
||||
};
|
||||
|
||||
const load = item => {
|
||||
return new Promise(resolve => {
|
||||
const $el = dom(tpl)
|
||||
.on('loadedmetadata', () => resolve($el))
|
||||
.attr('controls', 'controls')
|
||||
.attr('src', item.absHref);
|
||||
|
||||
.attr('controls', 'controls');
|
||||
if (settings.autoplay) {
|
||||
$el.attr('autoplay', 'autoplay');
|
||||
}
|
||||
addUnloadFn($el[0]);
|
||||
$el.attr('src', item.absHref);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -207,6 +207,11 @@ Session.prototype = {
|
|||
const item = this.item;
|
||||
Promise.resolve()
|
||||
.then(() => {
|
||||
each(dom('#pv-container *'), el => {
|
||||
if (typeof el.unload === 'function') {
|
||||
el.unload();
|
||||
}
|
||||
});
|
||||
dom('#pv-container').hide().clr();
|
||||
showSpinner(true, item.thumbSquare || item.icon, 200);
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue