-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Fix: p5 reference error in p5.MediaElement.loadPixels (ES module context) #8164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
98160e5
c4dcb8f
de7fae0
9511bd5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2303,7 +2303,7 @@ if (navigator.mediaDevices.getUserMedia === undefined) { | |
| * | ||
| * The first parameter, `type`, is optional. It sets the type of capture to | ||
| * use. By default, `createCapture()` captures both audio and video. If `VIDEO` | ||
| * is passed, as in `createCapture(VIDEO)`, only video will be captured. | ||
| * is passed, as in `createCapture(VIDEO)`, only video will be cshould work with tintaptured. | ||
| * If `AUDIO` is passed, as in `createCapture(AUDIO)`, only audio will be | ||
| * captured. A constraints object can also be passed to customize the stream. | ||
| * See the <a href="http://w3c.github.io/mediacapture-main/getusermedia.html#media-track-constraints" target="_blank"> | ||
|
|
@@ -4955,12 +4955,7 @@ class MediaElement extends p5.Element { | |
| this.setModified(true); | ||
| this._frameOnCanvas = this._pInst.frameCount; | ||
| } | ||
| } | ||
| loadPixels(...args) { | ||
| this._ensureCanvas(); | ||
| return p5.Renderer2D.prototype.loadPixels.apply(this, args); | ||
| } | ||
| updatePixels(x, y, w, h) { | ||
| }updatePixels(x, y, w, h) { | ||
|
||
| if (this.loadedmetadata) { | ||
| // wait for metadata | ||
| this._ensureCanvas(); | ||
|
|
@@ -5478,6 +5473,28 @@ class MediaElement extends p5.Element { | |
| } | ||
|
|
||
| p5.MediaElement = MediaElement; | ||
| // Fix for MediaElement.loadPixels renderer reference per instance | ||
| function attachMediaElementPixelMethods(p5Inst) { | ||
| p5Inst.MediaElement.prototype.loadPixels = function (...args) { | ||
| this._ensureCanvas(); | ||
| // Use the 2D renderer prototype method directly on the MediaElement | ||
| // MediaElement acts as its own 2D renderer context | ||
| return p5Inst.Renderer2D.prototype.loadPixels.apply(this, args); | ||
| }; | ||
|
|
||
| p5Inst.MediaElement.prototype.updatePixels = function (x, y, w, h) { | ||
| this._ensureCanvas(); | ||
| // Use the 2D renderer prototype method directly on the MediaElement | ||
| return p5Inst.Renderer2D.prototype.updatePixels.apply(this, x, y, w, h); | ||
| }; | ||
| } | ||
|
|
||
| // Attach to current instance if available | ||
| if (typeof p5 !== 'undefined') { | ||
| attachMediaElementPixelMethods(p5); | ||
|
||
| } | ||
|
|
||
|
|
||
|
|
||
| /** | ||
| * A class to describe a file. | ||
|
|
@@ -5842,6 +5859,9 @@ class File { | |
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| p5.File = File; | ||
|
|
||
| export default p5; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there was an accidental paste in here, let's make sure we don't update this line before we merge