Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fullscreen background videos for your webpages.
JavaScript Ruby
tag: v1.5.1

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
demo
spec/javascripts
src
Gemfile
Gemfile.lock
LICENSE
Rakefile
readme.md

readme.md

OKVideo

OKVideo is a jQuery plugin that allows for YouTube or Vimeo videos to be used as full-screen backgrounds on webpages. OKVideo aims to be customizable while making some basic decisions about how the plugin should control video. When using OKVideo, all videos will be served from Vimeo or YouTube based on a number of variables like browser, device, bandwidth, etc.

OKVideo uses the new YouTube IFrame API which does not require any Flash objects to be present on your website. This means that mobile devices will play video served by OKVideo. Content from Vimeo is served in a similar manner, although sometimes their videos will still be served in Flash.

Tested and working in Safari 5.1+, Chrome, Firefox 3.6+, IE 8+.

Usage

After including jQuery and the OKVideo plugin, instantiate OKVideo like so:

$(function(){
  $.okvideo({ source: '[:id]' }) // [:id] refers to a YouTube or Vimeo ID
}

OKVideo conveniently will accept and parse full urls from YouTube or Vimeo:

$(function(){
  $.okvideo({ source: '[:url]' }) // [:url] refers to a YouTube or Vimeo URL
}

OKVideo accepts a number of options. The below will embed a high definition video from YouTube with the audio set to 50% and log something to the console once the video has completed:

$(function(){
  $.okvideo({ 
      source: '[:url]',
      volume: 5,
      hd: true,
      onFinished: function(){ 
          console.log('finished video!')
      }
  });
}

You can also simply pass an id or url if no other options are desired:

$(function(){
  $.okvideo('[:url]') // [:url] refers to a YouTube or Vimeo URL
}

YouTube API Access

OKVideo gives you access to all of the YouTube player events. You can listen for all of the available player states: unstarted, ended, playing, paused, buffering, and cued. To listen for them simply pass OKVideo a function to the corresponding option noted below.

Options

option description default
source an id or url from vimeo or youtube null (required)
disablekeyControl enable or disable key control (youtube videos only) true
captions enable or disable captions (youtube videos only) false
loop loop the video true
high def control hd playback (youtube videos only) false
volume control the volume with an integer from 0 - 100 0
onFinished listen for the "finished" event (must be a function) null
unstarted listen for the "unstarted" event (must be a function) null
onPlay listen for the "play" event (must be a function) null
onPause listen for the "pause" event (must be a function) null
buffering listen for the "buffering" event (must be a function) null
cued listen for the "cued" event (must be a function) null

Tests

OKFocus tests with Jasmine. Once you've cloned the repo run bundle and then rake jasmine to test the source.

Something went wrong with that request. Please try again.