Giter Site home page Giter Site logo

video-commander's Introduction

VideoCommander

Disclaimer: lib is in development and some features might break

This library unifies video player APIs. Youtube, Vimeo, Facebook, Twitch and other players traditionaly have different APIs. VideoCommander provides one way of configuration, method calls & event handling, no matter which provider you decide to support.

Quick Start

Creating a player inside a container. Since VideoCommander is UMD library bear in mind that in browser environment you should be using ".default" to access video providers

import {registerProvider, VideoCommander} from 'video-commander'
import YoutubeProvider from 'video-commander/dist/vcProviderYoutube'
import VimeoProvider from 'video-commander/dist/vcProviderVimeo'

registerProvider('yt', YoutubeProvider)
registerProvider('vimeo', YoutubeProvider)

const ytPlayer = new VideoCommander({
  provider: 'yt',
  videoId: 'HAwC0swp96I'
})

const vimeoPlayer = new VideoCommander({
  provider: 'vimeo',
  videoId: '19231868'
})

Available methods

All the methods return Promises because some providers handle calls asynchronosly. The calls for which provider libraries execute return immediately resolved promise(Promise.resolve()) just for the sake of consistency. Usually you don't need to worry about the return values from this calls, but in case something is asynchronous and you need to wait for it this library supports it.

play():  Promise<void | Error>,
pause():  Promise<void | Error>,
stop():  Promise<void | Error>,
seek(seconds: number):  Promise<number | Error>,
mute():  Promise<number | Error>,
unMute():  Promise<number | Error>,
setVolume(volume: number):  Promise<number | Error>,
getVolume():  Promise<number | Error>,
getState():  Promise<any>,
getCurrentTime():  Promise<number | Error>,
getDuration():  Promise<number | Error>,
destroy():  Promise<void | Error>

Event handling

Subscribing to events

addListener(eventName: string, listener: Function)
removeListener(eventName: string, listener: Function)
removeAllListeners(eventName?: string) // if eventName is left out all event handlers are removed

VideoCommander instance dispatches:

READY, PLAY, PAUSE, STOP, SEEK, STATE_CHANGE, IDLE, ERROR, BUFFERING

Event map is available through:

import {VideoCommanderEvents} from 'video-commander'

video-commander's People

Contributors

apisurfer avatar

Stargazers

 avatar

Watchers

 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.