There had been a few posts on the forum asking about adding responsive videos. At the time I was unable to give a good answer. Now I have taken time to do a bit of research and I able to give a number of responsive video solutions. The solutions are in the order of difficulty, starting with the easiest solution. These are the players that I am going to be covering today.
- YouTube
- Sublime Video
- Wistia
- Simple HTML5 Video
- Simple HTML5 Video with flash fallback
- MediaElement.js
- Video.js
- Flowplayer
- JW Player
- Important info on FitVids.js
- Troubleshooting
YouTube
- Very easy to set up
- Needs FitVids.js so that it is responsive
- The video is hosted on YouTube
- Works easily on multiple devices and browsers
The easiest solution is to use YouTube. It works on multiple devices. In some countries YouTube plays an advertisement before the video. If you upload your own video this should not be the case. At the end of the video you get a grid with other videos. If you don’t want those then when embedding YouTube make sure you uncheck the “Show suggested videos when the video finishes”.

YouTube share settings
The rest of the solutions are for those who do not want to use the YouTube player and wish to host their own video.
Sublime Video
- Easy to set up with the code generator
- Need to add JavaScript code
- No need for FitVids.js
- Basic HTML5 code with flash fallback for IE8
- Works with self hosted videos and YouTube videos
Sublime offers a solution for your own hosted videos and also YouTube videos. Chose your option and then add the link to your media or for the YouTube videos add the video id.

Sublime Video Source
In the video setting the “Fit” option is very important.

Video Settings
At the end you can click on the “Get the Code” button at the bottom. You will then get a code like this.
|
1 2 3 4 5 6 |
<video id="video1" class="sublime" poster="http://media.sublimevideo.net/vpa/ms_800.jpg" width="640" height="360" data-autoresize="fit" data-uid="a55c1534" data-name="Midnight Sun" preload="none"> <source src="http://media.sublimevideo.net/vpa/ms_360p.mp4" /> <source src="http://media.sublimevideo.net/vpa/ms_720p.mp4" data-quality="hd" /> <source src="http://media.sublimevideo.net/vpa/ms_360p.webm" /> <source src="http://media.sublimevideo.net/vpa/ms_720p.webm" data-quality="hd" /> </video> |
The next step is to add the JavaScript. Every site has its own file.
|
1 |
<script type="text/javascript" src="//cdn.sublimevideo.net/js/emx0sm0y-beta.js"></script> |
Sublime Demo (YouTube video) Sublime Demo (hosted video)
Wistia
- Very Simple – only one file to upload
- the code is an iframe
- Hosted on the Wistia servers
- built in Video analytic
- Free version (3 videos / 5 GB bandwidth / branded player)
- Paid version begins at $25/mo
- has additional featured e.g. social sharing, call to action, require email to play and a few more which you can find here.
Solution 1
|
1 |
<iframe src="http://fast.wistia.net/embed/iframe/3bfl0abrog?controlsVisibleOnLoad=true&version=v1&videoHeight=360&videoWidth=640&volumeControl=true" allowtransparency="true" frameborder="0" scrolling="no" class="wistia_embed" name="wistia_embed" width="640" height="360"></iframe> |
Solution 2
There is a solution where Wistia supports responsive videos with their own code. So FitVids.js is not needed. To be able to achive this you need to chose the API option.

Select API Option
Then you need to add videoFoam: true to the same place where the videoWidth is.
Example code
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<div id="wistia_3bfl0abrog" class="wistia_embed" style="width:640px;height:360px;" data-video-width="640" data-video-height="360"> </div> <script charset="ISO-8859-1" src="https://fast.wistia.com/static/concat/E-v1%2CpostRoll-v1.js"></script> <script> wistiaEmbed = Wistia.embed("3bfl0abrog", { version: "v1", videoWidth: 640, videoHeight: 360, volumeControl: true, controlsVisibleOnLoad: true, videoFoam: true, plugin: { "postRoll-v1": { text: "Thank you for watching", link: "#", style: { backgroundColor: "#616161", color: "#ffffff", fontSize: "36px", fontFamily: "Gill Sans, Helvetica, Arial, sans-serif" } } } }); </script> |
Wistia own Demo Wistia my Demo
Simple HTML5 Video
- Need to create markup
- simple set up
- videos hosted on own site
- different players on every browser
- IE 8 and lower are not supported
The video tag is a new standard to display videos. I have added more information then you might need. To understand it best I have split this section into two parts.
HTML5 Markup
Here is a simple code example
|
1 |
<video src="http://testing.grappler.tk/files/2013/01/trailer_1080p.webm" width="320" height="240" controls="controls" preload="none"></video> |
So that the videos will work on multiple browser we will need multiple formats.
Here is a simple code example. I have also added a possibility to load a lower resolution video for smaller devices.
|
1 2 3 4 5 |
<video width="320" height="240" controls preload="metadata"> <source src="http://testing.grappler.tk/files/2013/01/trailer_1080p.mp4" type="video/mp4"/> <source src="http://testing.grappler.tk/files/2013/01/trailer_1080p.webm" type="video/webm"/> <source src="http://testing.grappler.tk/files/2013/01/trailer_1080p.ogv" type="video/ogg"/> </video> |
The video Tag has the following attributes. Some of them are easy to understand.
- global attributes – standard atributes like class and id
- autoplay
- preload - none, metadata, auto
- controls
- loop
- poster – poster=”/image.jpg”
- height
- width
- mediagroup – control two media elements(videos) through the first element(video)
- muted
- src – video link
Here are the source attributes.
- global attributes
- src
- type
- media
So to have a responsive HTML5 video you need to have this CSS.
|
1 2 3 4 5 |
video { width: 100%; max-width: 100%; height: auto; } |
You can use a service provided by video.js to create HTML5 video markup.
Video Files
There are three main video files.
| Format | Video Encoding | MIME-type |
|---|---|---|
| MP4 | H264 | video/mp4 |
| WebM | VP8 | video/webm |
| Ogg | Theora | video/ogg |
Not every browser supports all formats that is why we include all of them in the html. The easist way to get your video in the different formats is to use Miro converter
Miro Support said:
To get around this download an updated version of ffmpeg from here: http://ffmpeg.zeranoe.com/builds/
Take the ffmpeg.exe file from the updated build – and dropped it into C:\Program Files\Participatory Culture Foundation\Miro Video Converter\ffmpeg - replacing the existing ffmpeg.exe file and then convert without issue using MVC.
We will have to make a new release to update ffmpeg – but in the meantime you can use the workaround and you should be all set.
- Mozilla Firefox – WebM, Ogg
- Google Chrome – MP4, WebM, Ogg
- Opera – WebM, Ogg
- Safari – MP4
- Internet Explorer 9+ – MP4
- Internet Explorer 6-8 – No HTML5, Flash Only!
To test it your self Video Format Test
WordPress does not support webm at the moment and for that reason you will need to add the following code to your themes functions.php. If you are running a multisite you will need to check the list of allowed files.
|
1 2 3 4 5 |
add_filter( 'upload_mimes', 'custom_mimes' ); function custom_mimes( $mimes ){ $mimes['webm'] = 'video/webm'; return $mimes; } |
If you want any further reading then read this
Simple HTML5 Video with flash fallback
- The same points as for HTML video except with IE8 and lower support
This is how the code would look like with FlowPlayer being used as the backup.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<!-- "Video For Everybody" http://camendesign.com/code/video_for_everybody --> <video controls="controls" poster="http://testing.grappler.tk/files/2013/01/trailer_1080p.jpg" width="960" height="540"> <source src="http://testing.grappler.tk/files/2013/01/trailer_1080p.mp4" type="video/mp4" /> <source src="http://testing.grappler.tk/files/2013/01/trailer_1080p.webm" type="video/webm" /> <source src="http://testing.grappler.tk/files/2013/01/trailer_1080p.ogv" type="video/ogg" /> <object type="application/x-shockwave-flash" data="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" width="960" height="540"> <param name="movie" value="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" /> <param name="allowFullScreen" value="true" /> <param name="wmode" value="transparent" /> <param name="flashVars" value="config={'playlist':['http%3A%2F%2Ftesting.grappler.tk%2Ffiles%2F2013%2F01%2Ftrailer_1080p.jpg',{'url':'http%3A%2F%2Ftesting.grappler.tk%2Ffiles%2F2013%2F01%2Ftrailer_1080p.mp4','autoPlay':false}]}" /> <img alt="Big Buck Bunny" src="http://testing.grappler.tk/files/2013/01/trailer_1080p.jpg" width="960" height="540" title="No video playback capabilities, please download the video below" /> </object> </video> |
To save time you could use the Video for Everybody generator by Jonathan Neal to generate the code snippet according to your options. (FlashFox player seems to only resize if the browser is refreshed but does not change size dynamically,)
A complete explanation can be found at Kroc Camen’s site, the originator of this technique.
HTML5 with flash fallback Demo
MediaElement.js
- Standard Player
- out of the box responsive
- Supports HTML5 Video
- Automatically supports IE8 and lower
- Working WordPress plugin
- Does not need FitVids.js
How to get it running on your site.
- First you need to download the files.
- Open the zip file and then extract the build folder
- Move that build folder to your child theme. You can rename the folder if you want
- Load mediaelement-and-player.min.js and mediaelementplayer.min.css
- Load this javascript to activate the MediaElements player
12// activate mediaelementplayerjQuery('video,audio').mediaelementplayer(/* Options */); - Then you can include the HTML video code.
12345<video width="320" height="240" controls preload="metadata"><source src="http://testing.grappler.tk/files/2013/01/trailer_1080p.mp4" type="video/mp4"/><source src="http://testing.grappler.tk/files/2013/01/trailer_1080p.webm" type="video/webm"/><source src="http://testing.grappler.tk/files/2013/01/trailer_1080p.ogv" type="video/ogg"/></video>
MediaElement.js WordPress plugin
This is very simple. Install the plugin and then add this shortcode to the post or page. Just change the links to your video.
|
1 2 3 4 5 6 7 8 |
[video poster="http://mediaelement.grappler.tk/files/2013/02/trailer_1080p.jpg" mp4="http://mediaelement.grappler.tk/files/2013/02/trailer_1080p.mp4" webm="http://mediaelement.grappler.tk/files/2013/02/trailer_1080p.webm" ogg="http://mediaelement.grappler.tk/files/2013/02/trailer_1080p.ogv" width="100%" height="100%" ] |
MediaElement WordPress Plugin Demo
Flowplayer
- No need of FitVids.js
- Easy to use
- Customisable players
Simply add this HTML to page or post.
|
1 2 3 4 5 6 7 8 9 |
<script src="http://releases.flowplayer.org/5.3.2/flowplayer.min.js"></script> <link rel="stylesheet" type="text/css" href="http://releases.flowplayer.org/5.3.2/skin/minimalist.css" /> <div class="flowplayer play-button" data-ratio="0.5625"> <video controls="controls" preload="metadata" data-embed="false"> <source src="http://testing.grappler.tk/files/2013/01/trailer_1080p.mp4" type="video/mp4"/> <source src="http://testing.grappler.tk/files/2013/01/trailer_1080p.webm" type="video/webm"/> <source src="http://testing.grappler.tk/files/2013/01/trailer_1080p.ogv" type="video/ogg"/> </video> </div> |
Design your own player, Video attributes, Additional options
Video.js
- Flash Fallback
- WordPress Plugin
- Needs FitVids.js
- Load the JavaScript and Stylesheet
- Add the markup e.g.
123456789<link href="http://vjs.zencdn.net/c/video-js.css" rel="stylesheet"><script src="http://vjs.zencdn.net/c/video.js"></script><div class="video-js-wrapper"><video id="video-js-1" class="video-js vjs-default-skin" controls width="960" height="540" poster="http://testing.grappler.tk/files/2013/01/trailer_1080p.jpg" preload="auto" data-setup="{}"><source src="http://testing.grappler.tk/files/2013/01/trailer_1080p.mp4" type="video/mp4"/><source src="http://testing.grappler.tk/files/2013/01/trailer_1080p.webm" type="video/webm"/><source src="http://testing.grappler.tk/files/2013/01/trailer_1080p.ogv" type="video/ogg"/></video></div> - Add extra css
1234567.fluid-width-video-wrapper .video-js {position: absolute;top: 0;left: 0;width: 100%!important;height: 100%!important;} - Activate FitVids.js for Video.js
12345// FitVidsjQuery(document).ready(function(){// Target your #container, #wrapper etc.jQuery("#wrapper").fitVids({ customSelector: "div[class^='video-js-wrapper']"});});
Video.js WordPress plugin
The plugin does make it a bit easier to host the files. So install the plugin then add this code. Just change the video links and size.
|
1 2 3 |
<div class="video-js-wrapper" width="960" height="540"> [video poster="http://mediaelement.grappler.tk/files/2013/02/trailer_1080p.jpg" mp4="http://videojs.grappler.tk/files/2013/02/trailer_1080p.m4v" webm="http://videojs.grappler.tk/files/2013/02/trailer_1080p.webm" ogg="http://videojs.grappler.tk/files/2013/02/trailer_1080p.ogv" width="960" height="540"] </div> |
Videos.js WordPress Plugin Demo
JWPlayer
- Popular
- Not responsive out of the box
- Extra work for every video
Standard embed with responsive CSS Solution
I have found another way of making JWPlayer responsive. This should be a bit easier.
- Add this code to the page or post
1234567891011<script type="text/javascript" src="http://player.longtailvideo.com/jwplayer.js"></script><div id='player_1'></div><script type='text/javascript'>jwplayer('player_1').setup({file: "https://grapplerulrich.s3.amazonaws.com/html5video/trailer_1080p.mp4",width: "100%",height: "100%",stretching: "fill",flashplayer:"http://player.longtailvideo.com/player.swf"});</script> - Change the div id so that is different for every video. Make sure it matches the code in the JavaScript.
- Add this css
1234567891011121314#player_1_wrapper {width: 100%;position: relative;padding: 0;padding-bottom: 56.25%;}#player_1_wrapper object {position: absolute;top: 0;left: 0;width: 100%;height: 100%;}
You will need to add this css for every video. - So that the video keeps its proportion you will need to change the padding-bottom percentage. This is calculated video height/width*100. E.g. 540/960*100 =56.25%.
iframe Solution
The solution that I have for JW Player is a hack that Ethan from Longtailvideo sent me. Here is how to do it.
- Download the files
- Copy jwplayer folder to your child theme using a ftp client
- Create a html file in the child theme
- Paste this code in
12345678910111213141516171819202122232425262728293031323334353637<!DOCTYPE HTML><html><head><title>JWPlayer Reponsive Video</title><script type="text/javascript" src="http://player.longtailvideo.com/jwplayer.js"></script><style type="text/css">html, body {height: 100%;width: 100%;padding: 0;margin: 0;}#player {height: 100%;width: 100%;padding: 0;}</style></head><body><div id="player"></div><script type="text/javascript">jwplayer("player").setup({file: "http://testing.grappler.tk/files/2013/01/trailer_1080p.mp4",image: "http://testing.grappler.tk/files/2013/01/trailer_1080p.jpg",height: "100%",width: "100%",stretching: "exactfit",flashplayer:"http://player.longtailvideo.com/player.swf"});</script></body></html> - Change four links – Change the location of jwplayer.js, jwplayer.flash.swf, the video link and either update the image link or remove it.
- Then add an iframe with the link pointing to the newly created html file.
1<iframe width="940px" height="540px" src="http://grappler.tk/wp-content/themes/responsive-testing/jwplayer-iframe.html" frameborder="0" allowfullscreen=""></iframe> - Then we have to make sure that FitVids.js will work with this iframe. More on this here.
FitVids.js
Here are a couple of important things to know about FitVids.js.
The current version of FitVids.js conflicts with Video.js and MediaElement.js. That is why I would recommend using my version. It can be found on GitHub.
So that the video doesn’t distort script calculates the aspect ration. This is calculated by dividing the height by the width in the html code. That is why it is important the width and height is correct.
When adding iframes from other sources then it is necessary to add selectors. So that I can add an iframe from this site I would use this JavaScript. It is also important to check if www is used or not.
|
1 2 3 4 5 6 |
jQuery(document).ready(function(){ // Target your #container, #wrapper etc. jQuery("#wrapper").fitVids({ customSelector: "iframe[src^='http://grappler.tk']"}); jQuery("#wrapper").fitVids({ customSelector: "iframe[src^='http://www.grappler.tk']"}); jQuery("#wrapper").fitVids({ customSelector: "iframe[src^='http://fast.wistia.net']"}); }); |
Troubleshooting
Here are two links to help with troubleshooting the video setup
Multimedia Troubleshooting, longtailvideo.com
thanks Ulrich, awesome post on embedding video in WordPress
I am pleased you liked it.
Great post on responsive videos.
Thank you so much for the efforts and looking forward for the wordpress plugins review for videos.
Regards,
Sudeep Acharya
MediaElement and Video.js WordPress plugins are included. FlowPlayer and JWPlayer WordPress plugins will be added as soon as the bugs have been fixed or they have been updated.
Thanks Ulrich,
I have been using a WP youtube plugin with the responsive theme and it works perfectly on all platforms.
That’s good to know. Thank you for sharing this.
Regarding the non-iframe JW Player example. I don’t see how that can work. The CSS references a wrapper ID that doesn’t exist. Am I missing something?
The css wrapper id will be created by the JWPlayer JavaScript. You can see it in the demo.
I appreciate your help on this Ulrich. With your help, I was able to figure out the issue and it’s working nicely. Thanks so much!
No Problem.
. I will be including the WordPRess plugin also now that it has been updated to JWPlayer6.
All are good. i like this.
ulrich,
so sorry to bother you but wondering if you could share some of your genius with me. I am trying to get an iframe with an edge animation to be responsive along side of a video (that is working perfectly). for some reason i cannot get the iframe to respond. any suggestions please….
thanks, drotar
I would use something like this.
http://fitvidsjs.com/
Hi, any reason why Vimeo is not featured in this list?
Thanks,
Sridhar
The reason was that I have not been able to play a few vimeo videos on my android device. I think there are still some issues now. Another reason was I was looking into more self hosted solutions. FitVids.js does support vimeo so the process should be the same as YouTube.