Auto Stretch Youtube/HTML5 Video To Full Screen - VideoHero.js

File Size: 99 KB
Views Total: 3296
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Auto Stretch Youtube/HTML5 Video To Full Screen - VideoHero.js

VideoHero.js is a lightweight and configurable jQuery Video plugin for creating 'Hero' video on the webpage. Supports both Youtube and HTML5 videos.

The plugin automatically stretches the Youtube or HTML5 video player to fill the whole browser window while maintaining the original aspect ratio.

Also provides a volume control which enables the user to mute & unmute the playing video.

How to use it:

1. Load the stylesheet videohero.css in the header, and the JavaScript videohero.js after jQuery.

<link rel="stylesheet" href="dist/videohero.css">
<script src="" 
<script src="dist/videohero.js"></script>

2. Insert an HTML5 or Youtube video into the document using the following data attributes:

  • data-provider: Youtube or custom
  • data-videoid: Youtube video ID
  • data-poster: poster image
  • data-source: HTML5 video paths
<div class="video-hero" 
<div class="video-hero" 
     data-source='[{"source":"1.mp4", "type":"video/mp4"}, {"source":"1.webm", "type":"video/webm"}]'

3. Initialize the VideoHero.js plugin and done.


4. All default options to customize the plugin.

  provider: "youtube",
  videoid: "",
  source: "",
  poster: "",
  log: false,
  api: {
    url: "",
    param: "?url="
  attrs: {
    muted: true,
    autoplay: true,
    loop: true,
  classes: {
    container: {
      wrapper: "videohero videohero-wrapper",
      preparing: "preparing",
      ready: "ready",
      error: "error",
      provider: "videohero-provider-"
    video: "videohero-element",
    buttons: {
      mute: {
        self: "videohero-mute-button",
        on: "sound-off",
        off: "sound-on"
  i18n: {
    "mute": "Sound off",
    "unmute": "Sound on"

This awesome jQuery plugin is developed by jesus997. For more Advanced Usages, please check the demo page or visit the official website.