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

ember-wistia

v0.6.0

Published

Easy use components for wistia videos in an ember project

Downloads

42

Readme

Ember-wistia

Simple Ember addon for embedding wistia videos

Using this addon

This ember-cli addon is for embedding Wistia videos into your application through Wistia's public Javascript API. First install:

ember install ember-wistia

Example

You can see an example of ember-wistia videos at Society of Grownups.

Usage

Out of the box, using ember-wistia should be very simple. Simply use the wistia-video component, passing a Wistia matcher. A matcher can be found at the end of the URL for your video--it is typically a 10 character alphanumeric code.

<WistiaVideo @matcher="123example" />
or
{{wistia-video matcher="123example"}}

If you want to leverage Wistia's tracking and log which user is viewing your content, you can pass in an email as well.

<WistiaVideo @matcher="123example" @email="[email protected]" />
or
{{wistia-video matcher="123example" email="[email protected]"}}

Leveraging the Wistia Service

This addon adds videos through an Ember Service. The default component uses this service but it can be injected into other objects (such as Controllers).

wistia: Ember.inject.service()

This will allow you to call the public methods on the Wistia service directly.

// get the injected wistia service
let wistia = Ember.get(this, 'wistia');

// passes matcher to Wistia Service
wistia.addVideo('123example');

// optionally pass email
let email = '[email protected]'
wistia.addVideo('123example', email);

Binding Events

One of the best parts of Wistia's API is that you can bind functions to video events. For example, you can run a function anytime the video is paused.

// get the injected wistia service
let wistia = Ember.get(this, 'wistia');

let matcher = '123example';
wistia.bindVideoEvent(matcher, 'pause', () => { console.log('hi') });

The bindVideoEvent is flexible to handle any bind event found in the Wistia API documentation. This means it can handle a variable number of parameters:

// get the injected wistia service
let wistia = Ember.get(this, 'wistia');

let matcher = '123example';
// fire our function when the video is between 30 and 60 seconds
wistia.bindVideoEvent(matcher, 'betweentimes', 30, 60, () => { console.log('hi') });

Accessing Video Properties

The Wistia Service added in this addon also allows you to fetch the video object created by Wistia. This can be accessed through the getVideo method, which wrapped in an Ember Promise. For example, if you want to get a video's duration:

// get the injected wistia service
let wistia = Ember.get(this, 'wistia');

let matcher = '123example';
let duration;

// getVideo returns a video object
wistia.getVideo(matcher).then((video) => {
  duration = video.duration();
}).catch((error) => {
  // record a message or handle errors when no video is found
  console.log(error.msg);
});

For a list of methods that can be called from a Wistia video object, visit the Wistia Player API Documentation on Methods.

Additionally, you can pass an action into the default component called videoInitialize that will be fired once the video has loaded. This method returns the video object as well as the matcher passed in, allowing you to directly fire methods on the video object. For example, we can define an action in our controller:

// controller.js in your app
actions: {
  someAction(video, matcher) {
    video.bind('play', () => { console.log('Action fired') });
  }
}

You can then pass that in as a closure action into the component:

<WistiaVideo @matcher="123example" @videoInitialize={{action "someAction"}} />
or
{{wistia-video matcher="123example" videoInitialize=(action "someAction")}}

Styling

There is no styling set up by default for this component. However, there are a few classes you can easily leverage to style.

is-playing is a class applied to any video that is currently playing. This can be useful for when you have a page with multiple videos and wish to highlight the current one.

wistia_embed is the class applied to the div wrapper for the wistia video. To scale this video to its container, I recommend using this style:

.wistia_embed {
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  width: 100%;
}

This is the style used in the dummy application. You can see a video being run by running ember s. You can also view some examples by visiting Society of Grownups.

License

MIT

Installation

  • git clone this repository
  • npm install

Running Tests

  • npm test (Runs ember try:each to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://ember-cli.com/.