Giter Site home page Giter Site logo

okvideo's Introduction

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+, Mobile Safari, Chrome for iOS.

Usage

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

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

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

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

Want a YouTube playlist? I got u.

$(function(){
  $.okvideo({ playlist: {
                list: '[:id]', // a YT playlist id
                suggestedQuality: '[:quality]'
              }
           });
});

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: 50,
      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 type
video an id or url from vimeo or youtube null string
disablekeyControl enable or disable key control (youtube videos only) true boolaen
captions enable or disable captions (youtube videos only) false boolean
loop loop the video true boolean
high def control hd playback (youtube videos only) false boolean
volume control the volume (from 0 to 100) 0 number
annotations toggle annotations true boolean
autoplay autoplay the video true boolean
controls show player controls (youtube only) false boolean
onFinished listen for the "finished" event null function
unstarted listen for the "unstarted" event null function
onReady listen for the "ready" event null function
onPlay listen for the "play" event null function
onPause listen for the "pause" event null function
buffering listen for the "buffering" event null function
cued listen for the "cued" event null function
Playlist
playlist.list an id of a YouTube playlist null string
playlists.index which video the playlist begins with 0 number
playlists.startSeconds how many seconds into the first video to begin with 0 number
playlists.suggestedQuality the resolution of the video "default" string (small, medium, large, hd720, hd1080, highres, default)

Tests

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

okvideo's People

Contributors

jgv avatar bitpshr avatar yyolk avatar tasinttttttt avatar walfly avatar

Watchers

Yashi Lanka avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.