Giter Club home page Giter Club logo

videojs-thumbnail-sprite's Introduction

videojs-thumbnail-sprite

https://nodei.co/npm/videojs-thumbnail-sprite.png?downloads=true&downloadRank=true&stars=true

Build Status codecov

Video.js plugin to display preview image of a video at the point of time when hovering on progress bar

Table of Contents

  • Features
  • Demo
  • Install
    • Prerequisite
  • Usage
    • <script>
    • ES6 Module
    • Options
    • Rules to follow
  • Contribution
  • License

Features

  • Easy to use
    • From a sprite image extract multiple preview thumbnails and simply display them
  • Easy to configure
  • Typescript support
  • Support using multiple sprite images for each sections of video

Demo

You can see how it works on the demo site.

Install

# using npm
npm install --save videojs-thumbnail-sprite
# using yarn
yarn add videojs-thumbnail-sprite

Prerequisite

videojs-thumbnail-sprite uses Video.js as peer dependencies. To use this module, you should manually install those dependencies in your project.

Usage

<script>

Just load the module as you want, but you should load video.js module first, so that the plugin can access previously instantiated global videojs module reference.

<script src="//path/to/video.js"></script>
<script src="//path/to/videojs-thumbnail-sprite.js"></script>
<script>
  var player = videojs('video-id');

  player.thumbnailSprite({
    sprites: [
      {
        url: 'https://example.com/video.png',
        start: 0,
        duration: 10,
        interval: 2,
        width: 160,
        height: 90,
      },
    ],
  });
</script>

ES6 Module

Simple as previous usage. Just import the module as you want, but you should load video.js module first, so that the plugin can access previously instantiated global videojs module reference. Also, **you should import video.js module as a name of videojs, as the plugin will assume the name of imported video.js module as videojs.

import videojs from 'video.js';
import 'videojs-thumbnail-sprite';

const player = videojs('video-id');
player.thumbnailSprite({
  sprites: [
    {
      url: 'https://example.com/video.png',
      start: 0,
      duration: 10,
      interval: 2,
      width: 160,
      height: 90,
    },
  ],
});

Options

There is only single property provided currently: sprites

const options = {
  sprites: [
    {
      url: 'https://example.com/video-1.png',
      start: 0,
      duration: 10,
      interval: 2,
      width: 160,
      height: 90,
    },
    {
      url: 'https://example.com/video-2.png',
      start: 10,
      duration: 20,
      interval: 2,
      width: 160,
      height: 90,
    },
  ]
}
Option name Datatype Default value Description
url string '' URL of thumbnail sprite image
start number 0 Start point of time of the video section that this sprite image is covering
duration number 0 Duration of the video section that this sprite image is covering
width number 0 Width of preview thumbnail (px)
height number 0 Height of preview thumbnail (px)
interval number 0 Interval between each preview thumbnails of the video section that this sprite image is covering

You can use multiple sprite images in case that preview thumbnails for entire video is divided into several chunks. Just pass them as array of sprites, and the module will handle it on behalf of you.

Rules to follow

To make things happen preperly, there are some rules to follow:

  1. Each duration of video sections should not overlap each other. For example, if your first sprite image covers [0:00 ~ 10:00] and your second sprite image covers [5:00 ~ 15:00], then there is an overlap between them([5:00 ~ 10:00]). The module will emit warning on browser console if it catches any overlaps.
  2. width and height should be provided for each sprites. If not, even if the images are loaded those will not be displayed as expected.
  3. duration should be multiple of interval. From start point of time, at every interval seconds, the preview thumbnail will be displayed, so to display corresponding preview with hovering time correctly, follow this rule.

Contribution

Fork the repository, make changes, commit your work, and make Pull Request.

License

MIT Lisence

videojs-thumbnail-sprite's People

Contributors

cadenzah 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

Watchers

 avatar  avatar  avatar  avatar  avatar

videojs-thumbnail-sprite's Issues

예시 썸네일 스프라이트 업로드

Branch Name

issue/13-example-images

Type of Change

documentation

Priority

mid

Summary

예시로 사용할 수 있도록 한 동영상의 썸네일 스프라이트를 둘로 나누어 파일 형태로 Github 저장소에 업로드

Description of Change

대상 영상은 Bit Buck Bunny이다.

Reason for Change

이후 필요시 예시로 활용될 수 있도록

Expected Next or Associated Work (If exists)

  • DEMO 페이지 구현

Estimated Story Point

1

Reference (If exists)

Video.js Plugin 구현

Branch Name

issue/4-plugin-implement

Type of Change

feature

Priority

high

Summary

Video.js 플레이어에서 사용할 수 있는 플러그인 형태로서, 이미지로 된 썸네일 스프라이트를 요청을 통하여 받아왔을 때 플레이어 상에서 구간 탐색 중 해당 시점의 미리보기 이미지를 보여주는 기능을 구현

Description of Change

썸네일 스프라이트는 영상의 각각 시점마다의 재생 화면을 캡처하여 하나의 파일로 합쳐놓은 이미지이다. 이를 활용하면 사용자가 플레이어 상에서 프로그레스 바를 통하여 구간을 탐색할 때, 해당 탐색 시점의 재생 화면을 미리 보여주는 프리뷰 기능을 구현할 수 있다.

  • Video.js Plugin 구현 관련 문서 정독
  • Plugin options을 통하여 전달받을 값들에 대한 명세 설계
  • 기본 로직 구현
  • 한 영상에 대하여 여러 스프라이트가 존재하는 경우에 대한 로직 구현

Expected Next or Associated Work (If exists)

  • 코드 리팩토링 - #5
  • 테스트 코드 작성
  • README 작성

Estimated Story Point

10

Reference (If exists)

Travis CI 연동

Branch Name

issue/8-travis-ci

Type of Change

environment

Priority

mid

Summary

dev, master에 대한 푸시, PR 작성시 등에 CI 자동 적용하도록 Travis CI 연동

Description of Change

  • 장기적으로 다른 Contributor가 참여할 때 안정적인 커밋이 이루어질 수 있도록
  • 나태함

Expected Next or Associated Work (If exists)

  • README 작성 및 뱃지 발급 & 부착
  • 최종 발표 준비

Estimated Story Point

2

Reference (If exists)

작업 수행시 참고한 자료, 외부 링크 등을 기록해주세요.

이슈 템플릿 등록

Branch Name

issue/1-issue-template

Type of Change

github

Priority

low

Summary

작업 이슈 등록을 위한 Github Issue Template 파일 생성

Description of Change

작업 이슈 등록을 위한 Github Issue Template 파일 생성

Reason for Change

일관성있는 작업 이슈 관리

Expected Next or Associated Work (If exists)

  • 필요한 작업 이슈들 등록

Estimated Story Point

1

Reference (If exists)

customizable background color for timecode

Branch Name

master

Type of Change

design

Priority

mid

Summary

customizable background color for timecode

Description of Change

Adjustable background color for the timecode would be nice.

Reason for Change

When hovering over the progress bar to show the thumbnail, it can be hard to read the timecode. Especially when its a white image.
image

테스트 코드 작성

Branch Name

작업과 연결된 브랜치의 이름입니다. 이슈 제목과 이슈 내용에 맞추어 적절한 영문 이름을 지어주세요.

issue/1-tests

Type of Change

test

Priority

high

Summary

각 모듈 함수들에 대한 단위 테스트 및 플러그인의 통합 테스트

Description of Change

  • Unit test
  • Integrated test

Expected Next or Associated Work (If exists)

  • Travis CI 연동
  • README 작성
  • 뱃지 부착
  • 최종 발표 준비

Estimated Story Point

5

Reference (If exists)

작업 수행시 참고한 자료, 외부 링크 등을 기록해주세요.

코드 모듈화 - 리팩토링

Branch Name

issue/5-refactor-module

Type of Change

refactor

Priority

mid

Summary

플러그인 내의 함수들을 모듈로 분리하는 리팩토링 작업

Description of Change

단위 테스트의 용이함, 코드 가독성 향상 등을 위하여 플러그인 내부의 코드들을 별도 함수로 분리, 모듈화한다.

Expected Next or Associated Work (If exists)

  • 테스트 코드 작성 - #7

Estimated Story Point

3

Reference (If exists)

프로젝트 스캐폴딩

Branch Name

issue/2-project-scaffolding

Type of Change

environment

Priority

high

Summary

NPM 모듈 배포를 위한 구조에 걸맞는 프로젝트 디렉토리 스캐폴딩

Description of Change

  • NPM 프로젝트 초기화
    • 디렉토리 구조 초기화 - lib, tests
    • package.json
    • 기타 설정 파일들.gitignore, .npmignore
  • 타입스크립트 환경 적용 (tsconfig.json)
    • Rollup 빌드 환경 적용 (rollup.config.js)
  • Jest 테스트 환경 적용 (jest.config.js)
    • 테스트 관련 설정 (setupTests.ts)
  • Babel 환경 적용 (ES5 / .babelrc)
  • .nvmrc 명시 - v12.14.1
  • LICENSE 추가
  • Github Repo 설정
    • master 브랜치는 반드시 PR로만 푸시하도록 제한

Expected Next or Associated Work (If exists)

  • 테스트 및 배포 자동화가 이루어질 수 있는 CI/CD 환경 구축 (Travis CI? Github Actions?)

Estimated Story Point

1

Reference (If exists)

Demo 페이지 구현

Branch Name

issue/15-plugin-demo

Type of Change

demo

Priority

mid

Summary

플러그인 구현 내용을 확인할 수 있는 정적 웹 페이지를 GitHub Page를 통하여 배포

Description of Change

  • CRA를 사용하여 빠르게 React 프로젝트 구성 - yarn build
    • 서브 URI 처리 불가한 문제 발생, 자작 보일러플레이트 활용
  • Video.js React Enhanced를 사용하여 구성

Reason for Change

발표시 데모 시연을 생략하고 대신 데모 페이지를 안내하기 위함

Estimated Story Point

작업 완수에 필요한 예상 소요 Story Point를 산정해주세요. Story Point를 조정하는 경우, 조정한 뒤 조정 사유를 스레드로 추가해주세요.

README 작성

Branch Name

issue/10-readme

Type of Change

documentation

Priority

high

Summary

모듈 사용법을 소개하는 Document 작성

Description of Change

  • 적용법
  • 사용법
  • 뱃지

Expected Next or Associated Work (If exists)

  • 모듈 배포

Estimated Story Point

3

Reference (If exists)

작업 수행시 참고한 자료, 외부 링크 등을 기록해주세요.

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.