File tree Expand file tree Collapse file tree 2 files changed +23
-12
lines changed
Expand file tree Collapse file tree 2 files changed +23
-12
lines changed Original file line number Diff line number Diff line change 874874
875875 navigator . getUserMedia ( constraints , function ( stream ) {
876876 elt . src = window . URL . createObjectURL ( stream ) ;
877- elt . play ( ) ;
878- if ( cb ) {
879- cb ( stream ) ;
880- }
877+ elt . onloadedmetadata = function ( e ) {
878+ elt . play ( ) ;
879+ if ( cb ) {
880+ cb ( stream ) ;
881+ }
882+ } ;
881883 } , function ( e ) { console . log ( e ) ; } ) ;
882884 } else {
883885 throw 'getUserMedia not supported in this browser' ;
14791481 this . _prevTime = 0 ;
14801482 this . _cueIDCounter = 0 ;
14811483 this . _cues = [ ] ;
1482- this . pixelDensity = 1 ;
1484+ this . _pixelDensity = 1 ;
14831485
14841486 } ;
14851487 p5 . MediaElement . prototype = Object . create ( p5 . Element . prototype ) ;
16161618 this . canvas = document . createElement ( 'canvas' ) ;
16171619 this . drawingContext = this . canvas . getContext ( '2d' ) ;
16181620 }
1619- if ( this . canvas . width !== this . elt . videoWidth ) {
1620- this . canvas . width = this . elt . videoWidth ;
1621- this . canvas . height = this . elt . videoHeight ;
1621+ if ( this . canvas . width !== this . elt . width ) {
1622+ this . canvas . width = this . elt . width ;
1623+ this . canvas . height = this . elt . height ;
16221624 this . width = this . canvas . width ;
16231625 this . height = this . canvas . height ;
16241626 }
Original file line number Diff line number Diff line change @@ -193,10 +193,19 @@ p5.prototype.image =
193193 dy = sy || 0 ;
194194 sx = 0 ;
195195 sy = 0 ;
196- dWidth = sWidth || img . width ;
197- dHeight = sHeight || img . height ;
198- sWidth = img . width ;
199- sHeight = img . height ;
196+ if ( img . elt && img . elt . videoWidth && ! img . canvas ) { // video no canvas
197+ var actualW = img . elt . videoWidth ;
198+ var actualH = img . elt . videoHeight ;
199+ dWidth = sWidth || img . width ;
200+ dHeight = sHeight || img . width * actualH / actualW ;
201+ sWidth = actualW ;
202+ sHeight = actualH ;
203+ } else {
204+ dWidth = sWidth || img . width ;
205+ dHeight = sHeight || img . height ;
206+ sWidth = img . width ;
207+ sHeight = img . height ;
208+ }
200209 } else if ( arguments . length === 9 ) {
201210 sx = sx || 0 ;
202211 sy = sy || 0 ;
You can’t perform that action at this time.
0 commit comments