mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-22 05:11:20 -08:00
feat: add option to remove video source on destroy
- Introduced a new static property REMOVE_SRC_WHEN_DESTROY in Artplayer to control whether the video source should be removed when the player is destroyed. - Updated the destroy method in Artplayer to conditionally remove the video source based on the new property. - Removed the line that sets the video source to an empty string in the Template class's destroy method, as this is now handled in Artplayer. - Updated TypeScript definitions to include the new REMOVE_SRC_WHEN_DESTROY property.
This commit is contained in:
1 parent
cb3d391c34
commit
9bfd535e57
6 files changed
+9
-3
No files matched your search
@@ -360,6 +360,7 @@ class Artplayer extends (0, _emitterDefault.default) {
|
||||
return this.template.$video;
|
||||
}
|
||||
destroy(removeHtml = true) {
|
||||
if (Artplayer.REMOVE_SRC_WHEN_DESTROY) this.video.removeAttribute('src');
|
||||
this.events.destroy();
|
||||
this.template.destroy(removeHtml);
|
||||
instances.splice(instances.indexOf(this), 1);
|
||||
@@ -416,6 +417,7 @@ Artplayer.FLIP = [
|
||||
Artplayer.FULLSCREEN_WEB_IN_BODY = false;
|
||||
Artplayer.LOG_VERSION = true;
|
||||
Artplayer.USE_RAF = false;
|
||||
Artplayer.REMOVE_SRC_WHEN_DESTROY = true;
|
||||
if (_utils.isBrowser) {
|
||||
window.Artplayer = Artplayer;
|
||||
_utils.setStyleText('artplayer-style', (0, _indexLessDefault.default));
|
||||
@@ -5462,7 +5464,6 @@ class Template {
|
||||
if (0, _utils.isMobile) (0, _utils.addClass)(this.$player, 'art-mobile');
|
||||
}
|
||||
destroy(removeHtml) {
|
||||
this.$video.src = '';
|
||||
if (removeHtml) this.$container.innerHTML = '';
|
||||
else (0, _utils.addClass)(this.$player, 'art-destroy');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user