WordPress.org

Ready to get started?Download WordPress

Forums

MediaElement.js - HTML5 Video & Audio Player
Autoplaying even set to "false" (8 posts)

  1. imfm
    Member
    Posted 3 years ago #

    I'm trying to use this to play an mp4 file. I do want it to preload, but do not want it to autoplay. I set the autoplay attribute to false (autoplay="false"), but it's apparently being ignored by all the browsers I've tried. So is preload, for that matter; it will preload whether I set the attribute to "true" or "false", but I'm fine with preloading. Also, is there a way to set the default volume so it's not at 100%?

  2. johndyer
    Member
    Plugin Author

    Posted 3 years ago #

    The preload value should be "none".

    I'll take a look at the autoplay option.

  3. southernroutes
    Member
    Posted 3 years ago #

    I'm having the same problem with my MP3 files autoplaying regardless of what I try to include to stop them. Help?

  4. acurtisiv
    Member
    Posted 3 years ago #

    I have the same issue on videos with it just playing... even when auto play is set to false. Did anyone get this resolved... I would like to start using this plugin.

  5. georgestarcher
    Member
    Posted 3 years ago #

    I found if I edited the plugin's code I could fix the autoplay issue.
    Under "media_shortcode($tagName, $atts)"

    Change the preload and autoplay to this. Making them equal to empty values by default. Even having false in there causes the options to get added to any video when not specified.

    'preload' => '',
    'autoplay' => '',

  6. southernroutes
    Member
    Posted 3 years ago #

    John, can you comment on George's find? I'd like to hear an "official" position on this hack, though it sounds like it might do the trick?

  7. jwsand
    Member
    Posted 3 years ago #

    I am not an "official" voice for the plug in, but I do understand why @georgestarcher edit worked... I believe the proper way to fix this is to edit the following lines in the mediaelement-js-wp.php file (lines 177, 178, and 179):

    'preload' => 'false',
    'autoplay' => 'false',
    'loop' => 'false',

    To

    'preload' => false,
    'autoplay' => false,
    'loop' => false,

    What is happening here is that the code below this array, lines 188 through 238, is looking to see if the variables are true or not. If they are true then they set the option. The problem with the code is that the array defaults are set to strings instead of a bool. Therefore the variable, set as a string to false, is always true. So if you were to not put any argument into the short code then the default would be used, which in this case is 'false' as a string. Well the code below the array is looking to see if that variable is defined, which it is, therefore the if statement is true so it then defines the option/attribute. Therefore by removing the quotes in the code around the 'false' will change it to a bool default. In fact, the defaults of:

    'duration' => 'true',
    'progress' => 'true',
    'fullscreen' => 'true',
    'volume' => 'true',

    Should also have the quotes removed under this same theory.

  8. georgestarcher
    Member
    Posted 3 years ago #

    Thanks! Those edits work great for me.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic