3.0.4 • Published 3 years ago

@kissmybutton/motorcortex-subtitles v3.0.4

Weekly downloads
73
License
MIT
Repository
github
Last release
3 years ago

MotorCortex Subtitles

Subtitle library as a MotorCortex Incident

Installation

$ npm install @kissmybutton/motorcortex-subtitles
# OR
$ yarn add @kissmybutton/motorcortex-subtitles
import Subtitle from "@kissmybutton/motorcortex-subtitles";

Key Concepts / Features

MotorCortex Subtitles takes the capabilities of Subtitle library of parsing subtilte files. The library exposes just one Incident with the name "ParseText" which can parse supported subtitle files and add them to your clip. The duration is auto calculated from your subtitles. The container params of the subtitles clip should be the same with the parent clip.

Subtitle Formats supported

SRT or WebVTT

Documentation

Import and load the plugin to MotorCortex

import { HTMLClip, loadPlugin } from "@kissmybutton/motorcortex/";
import mySubsTextFile from "./subs.srt.js";
import SubtitlesDefinition from "@kissmybutton/motorcortex-subtitles/";
const Subtitles = loadPlugin(SubtitlesDefinition);
const clip = new HTMLClip({
  html: `
    <div class="container"></div>`,
  css: `
  .container{
    width:100%;
    height:100%;
    position:relative;
    background:#151515;
  }
`,
  host: document.getElementById("clip"),
  containerParams: {
    width: "720px",
    height: "640px",
  },
});

const subtitle = new Subtitles.ParseText(
  {
    fontSize: 14,
    textColor: "white",
    fontFamily: "Ubuntu",
    subtitles: mySubsTextFile,
    position: "bottom",
    maxWidth: 400,
    paddingBottom: 50,
  },
  {
    selector: ".container",
    containerParams: {
      width: "720px",
      height: "640px",
    },
  }
);

clip.addIncident(subtitle, 0);
clip.play();

Attributes

NameDescriptionDefaultType
fontSizeFont size in pixels of the subtitles12number
textColorThe color of the subtitleswhite-
fontFamilyFont family of the subtiltes'Ubuntu'string
subtitlesThe subtitles loaded text-string
positionPosition of the subtitles container top, center, bottombottomstring
maxWidthThe maximum width of the subtitles container in pixels"100%"number
paddingTopThe padding top value of the subtitles container in pixels0number
paddingBottomThe padding bottom value of the subtitles container in pixels0number

Demo

https://kissmybutton.github.io/motorcortex-subtitles/demo/

License

MIT License

Kiss My Button

3.0.4

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.0

3 years ago

2.0.5

3 years ago

2.0.0

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

4 years ago