mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-06-03 16:48:38 -04:00
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 => {
|
const load = item => {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const $el = dom(tpl)
|
const $el = dom(tpl)
|
||||||
.on('loadedmetadata', () => resolve($el))
|
.on('loadedmetadata', () => resolve($el))
|
||||||
.attr('controls', 'controls')
|
.attr('controls', 'controls');
|
||||||
.attr('src', item.absHref);
|
|
||||||
|
|
||||||
if (settings.autoplay) {
|
if (settings.autoplay) {
|
||||||
$el.attr('autoplay', '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 => {
|
const load = item => {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const $el = dom(tpl)
|
const $el = dom(tpl)
|
||||||
.on('loadedmetadata', () => resolve($el))
|
.on('loadedmetadata', () => resolve($el))
|
||||||
.attr('controls', 'controls')
|
.attr('controls', 'controls');
|
||||||
.attr('src', item.absHref);
|
|
||||||
|
|
||||||
if (settings.autoplay) {
|
if (settings.autoplay) {
|
||||||
$el.attr('autoplay', 'autoplay');
|
$el.attr('autoplay', 'autoplay');
|
||||||
}
|
}
|
||||||
|
addUnloadFn($el[0]);
|
||||||
|
$el.attr('src', item.absHref);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -207,6 +207,11 @@ Session.prototype = {
|
||||||
const item = this.item;
|
const item = this.item;
|
||||||
Promise.resolve()
|
Promise.resolve()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
each(dom('#pv-container *'), el => {
|
||||||
|
if (typeof el.unload === 'function') {
|
||||||
|
el.unload();
|
||||||
|
}
|
||||||
|
});
|
||||||
dom('#pv-container').hide().clr();
|
dom('#pv-container').hide().clr();
|
||||||
showSpinner(true, item.thumbSquare || item.icon, 200);
|
showSpinner(true, item.thumbSquare || item.icon, 200);
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue