[wp-trac] [WordPress Trac] #54788: Mute a video on WP with [video]

WordPress Trac noreply at wordpress.org
Tue Jan 11 07:50:11 UTC 2022


#54788: Mute a video on WP with [video]
--------------------------+-----------------------------
 Reporter:  prokium       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:  5.8
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Hi guys,

 What i did :

 I have uploaded a video on my self hosted WP (last release).
 On a page, I have put my shortcode as


 Behavior that I want too

 I would to autoplay it by default.
 So, i need to add the autoplay AND to mute the video.
 https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide
 It says : "
 Autoplay blocking is not applied to <video> elements when the source media
 does not have an audio track, **or if the audio track is muted**. Media
 with an active audio track are considered to be audible, and autoplay
 blocking applies to them. Inaudible media are not affected by autoplay
 blocking.
 "

 So i did that :


 {{{
 [video width="1920" height="1080"
 mp4="https://georgeabitbol.fr/content/uploads/2022/01/finalV4.mp4"
 autoplay="on" preload="auto" muted="true"][/video]
 }}}


 And i would like that

 {{{
 <video class="wp-video-shortcode" id="video-0-1" muted="1" autoplay="1"
 preload="auto" controls="controls" width="696" height="392">
 <source type="video/mp4" src="https://georgeabitbol.fr/wp-
 content/uploads/2022/01/finalV4.mp4?_=1">
 </video>
 }}}


 Behavior that i have


 {{{
 <video class="wp-video-shortcode" id="video-0-1" autoplay="1"
 preload="auto" controls="controls" width="696" height="392">
 <source type="video/mp4" src="https://georgeabitbol.fr/wp-
 content/uploads/2022/01/finalV4.mp4?_=1">
 </video>
 }}}


 What needs to change
 In  wordpress/wp-includes/media.php

 {{{
 $default_types = wp_get_video_extensions();
         $defaults_atts = array(
                 'src'      => '',
                 'poster'   => '',
                 'loop'     => '',
                 'autoplay' => '',
                 'preload'  => 'metadata',
                 'width'    => 640,
                 'height'   => 360,
                 'muted'          => '',
                 'class'    => 'wp-video-shortcode',
         );

 $html_atts = array(
                 'class'    => $atts['class'],
                 'id'       => sprintf( 'video-%d-%d', $post_id, $instance
 ),
                 'width'    => absint( $atts['width'] ),
                 'height'   => absint( $atts['height'] ),
                 'poster'   => esc_url( $atts['poster'] ),
                 'loop'     => wp_validate_boolean( $atts['loop'] ),
                 'autoplay' => wp_validate_boolean( $atts['autoplay'] ),
                 'muted' => wp_validate_boolean( $atts['muted'] ),
                 'preload'  => $atts['preload'],
         );


 foreach ( array( 'poster', 'loop', 'autoplay', 'preload', 'muted' ) as $a
 ) {
                 if ( empty( $html_atts[ $a ] ) ) {
                         unset( $html_atts[ $a ] );
                 }

 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54788>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list