GithubHelp home page GithubHelp logo

fluid-video's Introduction

Fluid Video

A spin-off version of the FitVids.js jQuery plugin for fluid video embeds.

Examples

Fluid Video requires jQuery 1.7+ and the addition of the CSS classes provided in style.css (which should be updated accordingly).

Basic Usage

$('iframe').fluidVideo();

Callbacks

Callbacks can be used to easily target vendors (e.g. YouTube, Vimeo, Viddler, etc.) for additional processing.

$('iframe').fluidVideo({
    vendors: {
        vimeo: {
            callback: function ($video, src) {
                // Set additional parameters for all Vimeo embeds.
                // See http://developer.vimeo.com/player/embedding
                $video.attr("src", src + "?title=0&byline=0&portrait=0&color=FFFFFF");
            }
        }
    }
});

Callbacks work with any vendor provided that the key (e.g. "youtube") appears in the video's src attribute. Vendor keys are not case-sensitive and may be written in camel case.

$('iframe').fluidVideo({
    vendors: {
        youtube: {
            callback: function ($video, src) {
                // callback function for YouTube videos...
            }
        },
        // e.g. the src attribute is "http://video.customvendor.com/video/123"
        customvendor: {
            callback: function ($video, src) {
                // callback function for custom vendor videos...
            }
        }
    }
});

CSS

The .fluid-video-wrapper CSS class can be overwritten with a custom class.

$('iframe').fluidVideo({
    parentClass: "my-parent-class"
});

The style.css file also includes a CSS class called .no-js that illustrates how to set a max-width: 100% fallback when JavaScript is not supported. The .no-js class is typically placed on the document's <html> tag and requires an additional line of JavaScript in the <head>.

<script>document.documentElement.className = document.documentElement.className.replace(/\bno-js\b/,'js');</script>

Demo

See Fluid Video in action: JSFiddle.

Change Log

v1.0

  • Initial commit

v1.1

  • Added callbacks for videos by vendor

fluid-video's People

Contributors

kyleweiner avatar

Watchers

James Cloos avatar Anthony Giza 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.