From b62811dec33564fe038087a7dea43cce11c8859e Mon Sep 17 00:00:00 2001 From: Dan Dumont Date: Mon, 12 Aug 2019 18:01:02 -0400 Subject: [PATCH] destroy videostream (if any) when file is destroyed. --- lib/file.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/file.js b/lib/file.js index 8bcfe22a..5a167947 100644 --- a/lib/file.js +++ b/lib/file.js @@ -119,7 +119,7 @@ class File extends EventEmitter { renderTo (elem, opts, cb) { if (typeof window === 'undefined') throw new Error('browser-only method') - render.render(this, elem, opts, cb) + this._stream = render.render(this, elem, opts, cb) } _getMimeType () { @@ -129,6 +129,8 @@ class File extends EventEmitter { _destroy () { this._destroyed = true this._torrent = null + this._stream && this._stream.destroy() + this._stream = null } }