Vide icon indicating copy to clipboard operation
Vide copied to clipboard

Mobile Video

Open b3nhartl3y opened this issue 9 years ago • 6 comments

Hello, great plugin, just wondering how you disable the video on mobile devices. I'm still seeing a call to the video even though it's not playing. Does it take any bandwidth up at all at mobile?

screen shot 2016-02-19 at 09 13 03

b3nhartl3y avatar Feb 19 '16 09:02 b3nhartl3y

Hey @b3nhartl3y. I'm having to do this myself, and I've found an option if you don't mind using another plugin (it is lightweight). Harvey.js is basically media queries in javascript: http://harvesthq.github.io/harvey/

So in the JS, you'll want something like:

Harvey.attach('screen and (min-width: 600px)', {
    on: function() {
        $('.home-hero').vide({
           // your stuff here
        });
    },
    off: function() {
        var instance = $('.home-hero').data('vide');
        instance.destroy();
    }
});

I've used 600px as an example minimum width. If the device is larger than that, it will follow 'on' and activate/load the Video. If it is smaller, you can grab your video instance and destroy it. That should mean that the video isn't loaded on mobile. Worked when I tested it on mobile.

carlwood avatar Jun 15 '16 14:06 carlwood

This seems like the biggest deal with this plugin. Would love a solution. Downloading a background video on mobile is irresponsible. Anyone have any ideas?

samuelorf avatar Aug 12 '16 04:08 samuelorf

Couldn't get Harvey to work, but actually the plugin is probably over kill now this is available:

matchmedia matchmedia usage

Here's an example of how I got it working:

var isMobile = window.matchMedia("only screen and (min-width: 400px)");

if (isMobile.matches) {
    var target = $('#vide')
    target.vide({
      mp4: "video.mp4",
      webm: "video.webm"
      ogv: "video.ogv",
      poster: "poster.png"
    }, {
        posterType: "jpg", 
        loop: true, 
        muted: true, 
        position: "0% 0%", 
        resize:true 
    });
}else{
    var target = $('#vide')
    target.vide({
      poster: "poster.png"
    }, {
        posterType: "jpg", 
        loop: true, 
        muted: true, 
        position: "0% 0%", 
        resize:true 
    });
}

This solution means no Video is even loaded, let alone run on mobile. Saves bandwidth and means you don't have to change any css to ensure the poster and videos fit in your element layout.

caleuanhopkins avatar Oct 14 '16 16:10 caleuanhopkins

This works, but your "isMobile" variable is counter-intuitive. I would change the "min-width" media-query to "max-width" so that "isMobile" is true.

lhazell avatar Mar 14 '17 18:03 lhazell

Simple Solution, This will trigger video fallback and shows image on mobile screens

@media screen and (max-width: 767px) { #parent-div-name video { display: none } }

officialprateek avatar Sep 02 '18 09:09 officialprateek

Couldn't get Harvey to work, but actually the plugin is probably over kill now this is available:

matchmedia matchmedia usage

Here's an example of how I got it working:

var isMobile = window.matchMedia("only screen and (min-width: 400px)");

if (isMobile.matches) {
    var target = $('#vide')
    target.vide({
      mp4: "video.mp4",
      webm: "video.webm"
      ogv: "video.ogv",
      poster: "poster.png"
    }, {
        posterType: "jpg", 
        loop: true, 
        muted: true, 
        position: "0% 0%", 
        resize:true 
    });
}else{
    var target = $('#vide')
    target.vide({
      poster: "poster.png"
    }, {
        posterType: "jpg", 
        loop: true, 
        muted: true, 
        position: "0% 0%", 
        resize:true 
    });
}

This solution means no Video is even loaded, let alone run on mobile. Saves bandwidth and means you don't have to change any css to ensure the poster and videos fit in your element layout.

Sure? Video starts playing

5brothers avatar Mar 21 '19 07:03 5brothers