Giter VIP home page Giter VIP logo

videojs-chapter-thumbnails's Introduction

videojs-chapter-thumbnails

Build Status

Video.js plugin for supporting WebVTT chapter thumbnails.

Example

Getting Started

Include

<!-- optional: default styles -->
<link href="/path/to/videojs.chapter-thumbnails.min.css" rel="stylesheet">

<script src="/path/to/videojs.chapter-thumbnails.min.js"></script>

Enable

videojs('player_id').chapter_thumbnails({
  src: '/path/to/chapters.vtt'
});

Note: There are multiple ways to enable plugins. For more information, please visit Video.js.

Options

label

Type: string
Default: English

language

Type: string
Default: en

src

Type: string

template

Type: Function
Default:

template(cue = {}, textTrack) {
  let cueText;

  // NOTE: if `cue.text` isn't parseable, just send it through instead of blowing up.
  // DRAGON: this probably opens up a possible script injection
  try {
    cueText = JSON.parse(cue.text || '{}');
  } catch (e) {
    cueText = cue.text;
  }

  const {
    image,
    title,
  } = cueText;

  const template = document.createElement('div');
  template.className = 'vjs-chapters-thumbnails-item';

  if (image) {
    const img = document.createElement('img');
    img.className = 'vjs-chapters-thumbnails-item-image';
    img.src = image;

    template.appendChild(img);
  }

  if (title) {
    const span = document.createElement('span');
    span.className = 'vjs-chapters-thumbnails-item-title';
    span.innerHTML = title;

    template.appendChild(span);
  }

  return template;
},

Provides for custom chapter templating. Must return either HTMLElement or string.

Example WebVTT file

Define chapters plugin by specifying a WebVTT spec.

WEBVTT

Chapter 1
00:00:00.000 --> 00:00:10.000
{
  "title":"Chapter 1",
  "image":"asset/img/chapter_1.png"
}

Contributing + Example

npm install -g grunt-cli

npm install

npm start

License

Code licensed under The MIT License.

videojs-chapter-thumbnails's People

Contributors

chemoish avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

videojs-chapter-thumbnails's Issues

Race condition

Pretty,,, sure there is still a race condition regarding the loading of chapter thumbnail menu items.

Not sure a course of action.

Memory leak.

Must dispose properly otherwise on videojs('player').dispose() an error will be thrown.

Uncaught TypeError: Cannot read property 'vdata1446698633391' of null

Missing css document

The "Getting started" section refers to a css file "videojs.chapter-thumbnails.min.css".
This file has not been included in the package.

A "dist" folder with this css file and the js files would have been a nice.

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.