Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

If <video> then don't play on mobile

Featured Replies

Hi, I have a html5 page using <video> tag and running .webm files. It all works quite smoothly.


However, I would like to not run the video on mobile devices and instead replace it with the jpeg poster.


This is the setup now:




<video id="video" preload="auto" poster="video1.jpg" autoplay muted loop>
<source src="video1.webm" type="video/webm" />
<source src="video1.ogv" type="video/ogv" />
<source src="video1.mp4" type="video/mp4" />
Your browser does not support the video tag. I suggest you upgrade your browser.
</video>


Any ideas? Thanks!

possibly use JS to check the width/device and then auto pause/stop the video rather than playing it?

Similar solution to above...

Edited by junior

seems a bit mean for mobile users that maybe on a wifi network for example (i mean one they've already paid for or at work/hotel/airport... ) ?

Remove the autoplay attribute it is not reliable across all browsers.

Instead use the methods suggested by @@junior or @@NOCK . But use it to start the video if the device is not a mobile.

Here is the code for juniors approach (window size) :

window.addEventListener('load', function load(event) {
    var video = document.getElementById('video');
    if(window.innerWidth >640){
        video.play();
    }
});

Edited by Nillervision

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.