@@ -26,7 +26,7 @@ export default class ComponentVideo extends ComponentImage {
2626 viUrl : 'https://player.vimeo.com/video/' ,
2727 loop : false ,
2828 poster : '' ,
29- muted : 0 ,
29+ muted : false ,
3030 autoplay : false ,
3131 controls : true ,
3232 color : '' ,
@@ -50,12 +50,13 @@ export default class ComponentVideo extends ComponentImage {
5050
5151 updatePropsFromAttr ( ) {
5252 if ( this . get ( 'provider' ) === defProvider ) {
53- const { controls, autoplay, loop } = this . get ( 'attributes' ) ! ;
53+ const { controls, autoplay, loop, muted } = this . get ( 'attributes' ) ! ;
5454 const toUp : ObjectAny = { } ;
5555
5656 if ( isDef ( controls ) ) toUp . controls = ! ! controls ;
5757 if ( isDef ( autoplay ) ) toUp . autoplay = ! ! autoplay ;
5858 if ( isDef ( loop ) ) toUp . loop = ! ! loop ;
59+ if ( isDef ( muted ) ) toUp . muted = ! ! muted ; // Update for muted
5960
6061 if ( ! isEmptyObj ( toUp ) ) {
6162 this . set ( toUp ) ;
@@ -111,6 +112,7 @@ export default class ComponentVideo extends ComponentImage {
111112 hasParam ( qr . color ) && this . set ( 'color' , qr . color ) ;
112113 qr . rel === '0' && this . set ( 'rel' , 0 ) ;
113114 qr . modestbranding === '1' && this . set ( 'modestbranding' , 1 ) ;
115+ qr . muted === '1' && this . set ( 'muted' , true ) ;
114116 break ;
115117 default :
116118 }
@@ -157,6 +159,7 @@ export default class ComponentVideo extends ComponentImage {
157159 attr . loop = ! ! this . get ( 'loop' ) ;
158160 attr . autoplay = ! ! this . get ( 'autoplay' ) ;
159161 attr . controls = ! ! this . get ( 'controls' ) ;
162+ attr . muted = ! ! this . get ( 'muted' ) ;
160163 }
161164
162165 return attr ;
@@ -206,6 +209,7 @@ export default class ComponentVideo extends ComponentImage {
206209 this . getAutoplayTrait ( ) ,
207210 this . getLoopTrait ( ) ,
208211 this . getControlsTrait ( ) ,
212+ this . getMutedTrait ( ) ,
209213 ] ;
210214 }
211215 /**
@@ -237,6 +241,7 @@ export default class ComponentVideo extends ComponentImage {
237241 name : 'modestbranding' ,
238242 changeProp : true ,
239243 } ,
244+ this . getMutedTrait ( ) ,
240245 ] ;
241246 }
242247
@@ -262,6 +267,7 @@ export default class ComponentVideo extends ComponentImage {
262267 } ,
263268 this . getAutoplayTrait ( ) ,
264269 this . getLoopTrait ( ) ,
270+ this . getMutedTrait ( ) ,
265271 ] ;
266272 }
267273
@@ -307,6 +313,20 @@ export default class ComponentVideo extends ComponentImage {
307313 } ;
308314 }
309315
316+ /**
317+ * Return object trait
318+ * @return {Object }
319+ * @private
320+ */
321+ getMutedTrait ( ) {
322+ return {
323+ type : 'checkbox' ,
324+ label : 'Muted' ,
325+ name : 'muted' ,
326+ changeProp : true ,
327+ } ;
328+ }
329+
310330 /**
311331 * Returns url to youtube video
312332 * @return {string }
@@ -318,10 +338,9 @@ export default class ComponentVideo extends ComponentImage {
318338 const list = this . get ( 'list' ) ;
319339 url += id + ( id . indexOf ( '?' ) < 0 ? '?' : '' ) ;
320340 url += list ? `&list=${ list } ` : '' ;
321- url += this . get ( 'autoplay' ) ? '&autoplay=1&mute=1' : '' ;
341+ url += this . get ( 'autoplay' ) ? '&autoplay=1' : '' ;
342+ url += this . get ( 'muted' ) ? '&mute=1' : '' ;
322343 url += ! this . get ( 'controls' ) ? '&controls=0&showinfo=0' : '' ;
323- // Loop works only with playlist enabled
324- // https://stackoverflow.com/questions/25779966/youtube-iframe-loop-doesnt-work
325344 url += this . get ( 'loop' ) ? `&loop=1&playlist=${ id } ` : '' ;
326345 url += this . get ( 'rel' ) ? '' : '&rel=0' ;
327346 url += this . get ( 'modestbranding' ) ? '&modestbranding=1' : '' ;
@@ -347,7 +366,8 @@ export default class ComponentVideo extends ComponentImage {
347366 getVimeoSrc ( ) {
348367 let url = this . get ( 'viUrl' ) as string ;
349368 url += this . get ( 'videoId' ) + '?' ;
350- url += this . get ( 'autoplay' ) ? '&autoplay=1&muted=1' : '' ;
369+ url += this . get ( 'autoplay' ) ? '&autoplay=1' : '' ;
370+ url += this . get ( 'muted' ) ? '&muted=1' : '' ;
351371 url += this . get ( 'loop' ) ? '&loop=1' : '' ;
352372 url += ! this . get ( 'controls' ) ? '&title=0&portrait=0&badge=0' : '' ;
353373 url += this . get ( 'color' ) ? '&color=' + this . get ( 'color' ) : '' ;
0 commit comments