File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ var canUseURL = typeof window . URL != 'undefined' ;
2
+
3
+ module . exports = function ( el , stream , callback ) {
4
+
5
+ function ready ( ) {
6
+ el . removeEventListener ( 'canplay' , ready ) ;
7
+ el . removeEventListener ( 'loadedmetadata' , ready ) ;
8
+ }
9
+
10
+ // check for srcObject
11
+ if ( typeof el . srcObject != 'undefined' ) {
12
+ video . srcObject = stream ;
13
+ }
14
+ // check for mozSrcObject
15
+ else if ( typeof el . mozSrcObject != 'undefined' ) {
16
+ el . mozSrcObject = stream ;
17
+ }
18
+ else {
19
+ el . src = canUseURL ? URL . createObjectURL ( stream ) : stream ;
20
+ }
21
+
22
+ // if no callback has been provided, return without monitoring the readiness
23
+ if ( ! callback ) {
24
+ return ;
25
+ }
26
+
27
+ // if the video is ready now, then capture the frame
28
+ if ( el . readyState >= 3 ) {
29
+ return callback ( ) ;
30
+ }
31
+ else {
32
+ el . addEventListener ( 'canplay' , ready , false ) ;
33
+ el . addEventListener ( 'loadedmetadata' , ready , false ) ;
34
+ }
35
+
36
+ } ;
You can’t perform that action at this time.
0 commit comments