Giter Site home page Giter Site logo

oddworks-jwplayer-provider's Introduction

Oddworks JWPlayer Provider

An JWPlayer provider plugin for the Oddworks content server.

Installation

Install the npm package as a Node.js library:

npm install --save oddworks-jwplayer-provider

For full JWPlayer API documentation see https://developer.jwplayer.com/jw-platform/reference/v1/.

Oddworks Server Integration

The Oddworks JWPlayer provider is designed to be integrated with an Oddworks server catalog, specifically as a provider. To initialize the plugin in your server:

const jwplayerProvider = require('oddworks-jwplayer-provider');

// See https://github.com/oddnetworks/oddworks/tree/master/lib/services/catalog#patterns
// for more information regarding an Oddcast Bus.
const bus = createMyOddcastBus();

const options = {
    bus: bus,
    apiKey: process.env.JWPLAYER_API_KEY,
    secretKey: process.env.JWPLAYER_SECRET_KEY
};

jwplayerProvider.initialize(options).then(provider => {
    console.log('Initialized provider "%s"', provider.name);
}).catch(err => {
    console.error(err.stack || err.message || err);
});

JW API credentials can also be passed in on the oddworks Channel object in the secrets: {} hash like so

{
    type: 'channel',
    id: 'cartoon-network',
    secrets: {
        jwApiKey: '',
        jwSecretKey: ''
    }
}

The initialization process will attach Oddcast listeners for the following queries:

  • bus.query({role: 'provider', cmd: 'get', source: 'jwplayer-playlist-provider'})
  • bus.query({role: 'provider', cmd: 'get', source: 'jwplayer-video-provider'})

To use them you send Oddcast commands to save a specification object:

// To create a collection based on a JWPlayer playlist:
bus.sendCommand({role: 'catalog', cmd: 'setItemSpec'}, {
    channel: 'abc',
    type: 'collectionSpec',
    source: 'jwplayer-playlist-provider',
    playlist: {key: '123456'}
});

// To create a video based on a JWPlayer video:
bus.sendCommand({role: 'catalog', cmd: 'setItemSpec'}, {
    channel: 'abc',
    type: 'videoSpec',
    source: 'jwplayer-video-provider',
    video: {key: '123456'}
});

JWPlayer API Client

You can create a stand-alone API client outside of the Oddworks provider:

const jwplayerProvider = require('oddworks-jwplayer-provider');

const client = jwplayerProvider.createClient({
    bus: bus,
    apiKey: process.env.jwplayer_API_KEY,
    secretKey: process.env.jwplayer_SECRET_KEY
});

Client Methods

All methods return a Promise.

  • client.getPlaylists()
  • client.getPlaylist({playlistId})
  • client.getVideosByPlaylist({playlistId})
  • client.getVideo({videoId})

License

Apache 2.0 © Odd Networks

oddworks-jwplayer-provider's People

Contributors

aljachimiak avatar blainsmith avatar kixxauth avatar

Watchers

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