We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 13ef5bd + b20d0f8 commit 78d7cf8Copy full SHA for 78d7cf8
src/dom/dom.js
@@ -2173,10 +2173,14 @@ p5.Element.prototype.remove = function() {
2173
// stop all audios/videos and detach all devices like microphone/camera etc
2174
// used as input/output for audios/videos.
2175
if (this instanceof p5.MediaElement) {
2176
- const tracks = this.elt.srcObject.getTracks();
2177
- tracks.forEach(function(track) {
2178
- track.stop();
2179
- });
+ this.stop();
+ const sources = this.elt.srcObject;
+ if (sources !== null) {
+ const tracks = sources.getTracks();
2180
+ tracks.forEach(track => {
2181
+ track.stop();
2182
+ });
2183
+ }
2184
}
2185
2186
// delete the reference in this._pInst._elements
0 commit comments