Giter Site home page Giter Site logo

patricktran / shaka-player-ui-controls Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 3.0 200 KB

The missing UI controls package for Shaka Player! Vertical volume slider, rewind, and fast forward controls.

JavaScript 87.07% CSS 12.93%
shaka-player shaka video-player video media-control volume-control rewind-video

shaka-player-ui-controls's Introduction

shaka-player-ui-controls

The missing UI controls package for Google Shaka Player!
Vertical volume slider, rewind, and fast forward controls.

NPM JavaScript Style Guide


screenshot


Install

npm install --save shaka-player-ui-controls

⚠️ Also install Shaka Player - Shaka Player Documentation

screenshot


UI Controls Included

  • Vertical Volume Slider

  • Rewind:

    • 5 Seconds
    • 10 Seconds
    • 30 Seconds
  • Fast Forward:

    • 5 Seconds
    • 10 Seconds
    • 30 Seconds

Demo

Click here to see a demo on codesandbox.


Usage

//step 1) import packages/css

import {
  Player as ShakaPlayer,
  ui as ShakaUI,
} from "shaka-player/dist/shaka-player.ui";

import "shaka-player/dist/controls.css";

import {
  ForwardFiveButton,
  ForwardTenButton,
  ForwardThirtyButton,
  RewindFiveButton,
  RewindTenButton,
  RewindThirtyButton,
  VerticalVolume,
} from "shaka-player-ui-controls";

import "shaka-player-ui-controls/dist/main.css";

//step 2) register control elements to ShakaUI

//vertical volume control
ShakaUI.Controls.registerElement(
  "vertical_volume",
  new VerticalVolume.Factory()
);

//rewind controls
ShakaUI.Controls.registerElement("rewind_5", new RewindFiveButton.Factory());
ShakaUI.Controls.registerElement("rewind_10", new RewindTenButton.Factory());
ShakaUI.Controls.registerElement("rewind_30", new RewindThirtyButton.Factory());

//fast forward controls
ShakaUI.Controls.registerElement("forward_5", new ForwardFiveButton.Factory());
ShakaUI.Controls.registerElement("forward_10", new ForwardTenButton.Factory());
ShakaUI.Controls.registerElement(
  "forward_30",
  new ForwardThirtyButton.Factory()
);

//step 3) create your custom ui config
//https://shaka-player-demo.appspot.com/docs/api/tutorial-ui-customization.html

const uiConfig = {
  controlPanelElements: [
    "rewind_30",
    "rewind_10",
    "rewind_5",
    "play_pause",
    "forward_5",
    "forward_10",
    "forward_30",
    "vertical_volume",
  ],
};

...

//step 4) pass in your custom ui config to shaka player

//getting reference to video and video container on DOM
const video = document.getElementById('video');
const videoContainer = document.getElementById('video-container');

//initialize shaka player
var player = new ShakaPlayer(video);

//setting up shaka player UI overlay
const ui = new ShakaUI.Overlay(player, videoContainer, video);

//pass in custom uiConfig
ui.configure(uiConfig);

License

MIT © patricktran

shaka-player-ui-controls's People

Contributors

patricktran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

shaka-player-ui-controls's Issues

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.