Support » Plugin: Featured Video Plus » No auto-play & no JavaScript API from YouTube

  • Having updated to the latest version I can’t manage to get it to play automatically using “Replace featured image with video on click and auto play if possible” anymore.

    It also appears that something in the plugin’s general.php, which used to add some JavaScript to listen for YouTube player events and show/hide parent elements on pause/play, is no longer present.

    I’ve recently taken over the development of my site from someone else, so I don’t know if the old version had been modified in someway, but do you have any thoughts on why the behavior of the plugin has changed?

    Here’s my dev site with the featured video on a slider:
    http://www.tolkiensociety.org/wordpress/

    Essentially, when the video is playing I want the post name and categories to be hidden and for them to reappear when the video ends or is paused. I want the slider nav elements to remain in place regardless. It used to do this with the old version of the plugin in Chrome (it partially worked in Firefox and not at all in IE).

    https://wordpress.org/plugins/featured-video-plus/

Viewing 2 replies - 1 through 2 (of 2 total)
  • I don’t see any sign of YouTube autoplay support in the click-image-to-load-video mode of FVP (in the current version anyway, I have not used older versions).

    I did my own little hack that seems to work:

    Added the following to my template:

    wp_enqueue_script( 'youtube', 'https://www.youtube.com/iframe_api', array() , '1', true );

    Added this to featured-video-plus/js/frontend.js, at the end of the jQuery.post() handler (line 85 approximately):

    if (/youtube\.com|youtu\.be/i.test(data.html)) {
      var id = $('#DOMWindow iframe').attr('id');
      new YT.Player(id, {events: {onReady: function(event){
        event.target.playVideo();
      }}})
    }

    This snippet checks to see if the video HTML mentions a YouTube domain, and if so uses the YouTube IFrame API to play the video. Seems to work on desktop but i suspect it may not work on mobile, since you usually have to trigger play from a user-generated UI event (click/tap) to autoplay, but that’s a limitation that’s hard to avoid with FVP’s ajax content loading technique. Will do some testing and see. Hopefully this gets fixed in a future version and I can remove my hack.

    Thread Starter danielhelen

    (@danielhelen)

    I gave that a go, but I couldn’t get it to work.

    So instead I’ve modified to the Featured Video plugin to do exactly what I needed it to.

    But if this does get sorted out in a future update I will certainly consider going back to this plugin.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘No auto-play & no JavaScript API from YouTube’ is closed to new replies.