WordPress.org

Ready to get started?Download WordPress

Forums

mb.YTPlayer for background videos
A way to de-activate for certain resolutions? (2 posts)

  1. choazie
    Member
    Posted 8 months ago #

    Hey Matteo! Last question, I promise! Your lovely plugin is a very important element to my site so I'm keen to get it working perfectly.

    I have my video background set to autoplay and have a fallback div for resolutions under 1050px (mobile devices). The issue is that <1050px desktop browsers are seeing the fallback div and hearing the audio from mb.YTPlayer at the same time. I only want these people to see the fallback div and not see mb.YTPlayer at all.

    Can I disable the player for certain resolutions with a media query or would I instead need to input something into the .js file?

    Any help on this would be very much appreciated! Thanks.

    Page: http://www.ilovestvincent.com

    http://wordpress.org/plugins/wpmbytplayer/

  2. pupunzi
    Member
    Plugin Author

    Posted 8 months ago #

    Hi,
    You can only do that via javascript creating your own function to detect screen size on resizing and removing the YTPlayer container if the resolution is lower than 1050. You can't do it via CSS.

    Should be something like:

    $(window).on("resize",function(){
      var video = $("#bgndVideo1");
      if($(window).width()<1050 && ! video.attr("paused")){
        $("#bgndVideo1").pauseYTP();
        video.attr("paused", true)
    }else{
        $("#bgndVideo1").playYTP();
        video.attr("paused", false)
    }
    });
    $(window).trigger("resize");

Reply

You must log in to post.

About this Plugin

About this Topic