Solved

Responsive HTML5 video

Posted on 2016-09-07
1
50 Views
Last Modified: 2016-09-08
I am trying to use media queries in html to detect if the page is on phone or desktop than video will play different clip. However, It is not really working. I wonder how to fix it... the idea is from here https://www.iandevlin.com/blog/2012/08/html5/responsive-html5-video

<video controls preload="none" loop muted autoplay poster='img/first_frame.png' class="fullscreen-bg__video" onclick="this.play(); ">
<source src="video/TankingTanksConversion04.mp4" type="video/mp4" media="all and (max-width:480px)">
<source src="video/TankingTanksConversion03.mp4" type="video/mp4">
</video>

Open in new window


Thanks
0
Comment
Question by:mingchih
1 Comment
 
LVL 25

Accepted Solution

by:
lenamtl earned 500 total points
ID: 41789519
You don't have to detect it, I should automatically display correctly based on device and browser. have more than one format will help.

Be aware that this may not play well on small device due to bandwidth restriction, specially for Auto play, plus some browser may not display the video at all.
Also don't forget to put a poster as image replacement for this case.

<video controls preload="none" poster="poster.png"> 
   <source src="video1.mp4" type="video/mp4"> 
   <source src="video1.webm" type="video/webm"> 
  <source src="video1.ogv" type="video/ogv"> 
</video> 

Open in new window

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question