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.
1 parent 13ef5bd commit 7da1cc2Copy full SHA for 7da1cc2
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();
+ let sources = this.elt.srcObject;
+ if (sources !== null) {
+ let 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