File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed
packages/builder-web-core/widgets-native/html-iframe-youtube Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -22,11 +22,31 @@ export class HtmlIframeYoutube extends HtmlIframe {
22
22
loading,
23
23
sandbox,
24
24
referrerpolicy,
25
- src : yturl ( video ) ,
25
+ src : yturl ( video , { autoplay : true } ) ,
26
26
} ) ;
27
27
}
28
28
}
29
29
30
- function yturl ( video : string ) : string {
30
+ function yturl (
31
+ video : string ,
32
+ opt ?: {
33
+ autoplay ?: boolean ;
34
+ }
35
+ ) : string {
36
+ const q = { } ;
37
+
38
+ if ( opt ?. autoplay ) {
39
+ q [ "autoplay" ] = "1" ;
40
+ }
41
+
42
+ if ( Object . keys ( q ) . length > 0 ) {
43
+ return `https://www.youtube.com/embed/${ video } ?${ buildq ( q ) } ` ;
44
+ }
45
+
31
46
return `https://www.youtube.com/embed/${ video } ` ;
32
47
}
48
+
49
+ const buildq = ( q : object ) : string =>
50
+ Object . keys ( q )
51
+ . map ( ( k ) => `${ encodeURIComponent ( k ) } =${ encodeURIComponent ( q [ k ] ) } ` )
52
+ . join ( "&" ) ;
You can’t perform that action at this time.
0 commit comments