npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

angularjs-video-background

v1.8.2

Published

angularjs-video-background is an [Angular.js](http://angularjs.org/) YouTube video background player directive. It stresses simplicity and performance.

Downloads

2

Readme

angularjs-video-background

angularjs-video-background is an Angular.js YouTube video background player directive. It stresses simplicity and performance.

angular-video-bg Screenshot

Demo

Play with the Plunker example

You can also see a demo of the directive here: Angular YouTube Video Background

Download

You can also install the package using Bower.

yarn add angularjs-video-background

Or add it to your package.json file:

dependencies: {
  "angularjs-video-background": "~1.8"
}

No dependencies (besides Angular) are required!

The Basics

To use the library, include the JS file on your index page, then include the module in your app:

app = angular.module('myApp', ['angularjsVideoBackground'])

The directive itself is simply called video-bg. The only required attribute is either videoId (which should be a YouTube video ID) or playlist (which should be an array of video objects, see example in advanced usage section below).

<video-bg video-id="video.id"></video-bg>

Inline Options

There are a number of options that be configured inline with attributes:

| Option | Default | Description | | -------------------- | ------------------- | ------------------------------------------------------------------------------------------- | | ratio | 16/9 | Aspect ratio for the supplied videoId. | | loop | true | If set to false, video will not automatically replay when it reaches the end. | | mute | true | If set to false, the video's sound will play. | | mobile-image | YT video thumb | Background image to display if user is on phone or tablet (videos cannot autoplay on mobile devices), default is YouTube video thumbnail. | | start | null | Video start time in seconds. If set, video will play from that point instead of beginning. | | end | null | Video end time in seconds. If set, video will play until that point and stop (or loop). | | content-z-index | 99 | If set, will replace the z-index of content within the directive. | | allow-click-events | false | If set to true, users will be able to click video to pause/play it. | | player-callback | null | If provided, player callback method will be called with the YouTube player object as the first and only argument. |

Example:

<video-bg video-id="video.id" ratio="4/3" loop="false" mute="false" mobile-image="'/img/background-img.png'" start="30" end="120" content-z-index="500" allow-click-events="true"></video-bg>

Advanced Usage

The documentation above is sufficient for most use-cases; however, there are other options below for those that need more advanced integration.

Playlist Capability

If instead of playing a single video, you need to play several videos in a playlist, you should use the playlist attribute instead of the videoId attribute. The playlist attribute accepts an array of video objects. Each video object must have a 'videoId' property at minimum. Other valid properties that it can have are 'start', 'end', 'mute', and 'mobileImage'. These all do the same thing as the corresponding options on the directive, however, instead of applying to every video they only apply to the current video. Example below of using the playlist attribute:

angular.module('myApp').controller('VideoCtrl', function($scope) {

    // Array of videos to use as playlist
    $scope.videos = [{
        videoId: 'some_video',
        mute: false
    },{
        videoId: 'some_other_video',
        start: 10,
        end: 50
    }];

});
<video-bg playlist="videos"></video-bg>

If you dynamically change this videos array (e.g. add a new video to the list), the new playlist will be loaded and played accordingly.

YouTube Player API

If you need more control over the video (for example, if you need to play/pause the video on a button click), provide a method with "player" as the only argument to the player-callback attribute.

<video-bg video-id="video.id" player-callback="callback(player)"></video-bg>
angular.module('myApp').controller(['$scope', function($scope) {
    $scope.callback = function(player) {
        $scope.pauseVideo = function() {
            player.pauseVideo();
        };
        $scope.playVideo = function() {
            player.playVideo();
        };
    };
});

The player object gives you complete access to all of the methods and properties on the player in the YouTube IFrame API.

Browser Support

Tested and working in Chrome, Firefox, Safari, Opera and IE 9+.

To get the project running, you'll need NPM and Yarn. Run npm install or yarn install to install all dependencies. Then run grunt serve in the project directory to watch and compile changes.

If you create new unit test, you can run grunt test to execute all of the unit tests. Try to write tests if you contribute.

Potential Features down the road

  • Add support for HTML5, Vimeo videos instead of just YouTube videos.