├── .editorconfig ├── .eslintrc ├── .github ├── FUNDING.yml └── workflows │ └── node.js.yml ├── .gitignore ├── LICENSE ├── README.md ├── index.spec.ts ├── index.ts ├── jest.config.js ├── package-lock.json ├── package.json └── tsconfig.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_size = 2 8 | indent_style = space 9 | insert_final_newline = true 10 | max_line_length = 80 11 | trim_trailing_whitespace = true 12 | 13 | [*.md] 14 | max_line_length = 0 15 | trim_trailing_whitespace = false 16 | 17 | [COMMIT_EDITMSG] 18 | max_line_length = 0 19 | 20 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "airbnb", 3 | "rules": { 4 | "no-console": [ 5 | "error", 6 | { 7 | "allow": [ 8 | "warn", 9 | "error", 10 | "info" 11 | ] 12 | } 13 | ], 14 | "prefer-promise-reject-errors":[ 15 | "off" 16 | ], 17 | "symbol-description": [ 18 | "off" 19 | ], 20 | "no-underscore-dangle": [ 21 | "off" 22 | ], 23 | "no-param-reassign": [ 24 | "off" 25 | ], 26 | "import/no-unresolved": [ 27 | "off" 28 | ] 29 | }, 30 | "env": { 31 | "browser": true, 32 | "node": true 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [imshaikot] 4 | ko_fi: sahriar74587 5 | -------------------------------------------------------------------------------- /.github/workflows/node.js.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: Node.js CI 5 | 6 | on: 7 | push: 8 | branches: [ master ] 9 | pull_request: 10 | branches: [ master ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | strategy: 18 | matrix: 19 | node-version: [12.x, 14.x, 16.x] 20 | # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ 21 | 22 | steps: 23 | - uses: actions/checkout@v2 24 | - name: Use Node.js ${{ matrix.node-version }} 25 | uses: actions/setup-node@v2 26 | with: 27 | node-version: ${{ matrix.node-version }} 28 | cache: 'npm' 29 | - run: npm ci 30 | - run: npm run build --if-present 31 | - run: npm test 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # See https://help.github.com/ignore-files/ for more about ignoring files. 3 | 4 | # dependencies 5 | /node_modules 6 | 7 | # production 8 | /build 9 | 10 | lib/ 11 | umd/ 12 | 13 | # misc 14 | .DS_Store 15 | npm-debug.log* 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Shariar Shaikot 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Convert and generate URL of WebVTT from .srt subtitle file on the fly over Browser/HTML5 environment

2 | 3 | HTMLMediaElement/Video doesn't support `.srt` (SubRip Track) format subtitle as its `` source - in order to show captions of your video track either you have to convert the SRT file to WebVTT or write it on your own. Because `` requires a valid URL of `.vtt` (Web Video Text Track) formated subtitle track. 4 | This library will let you do this on the fly and will give you an URL to set the source of caption track. 5 | 6 |

7 | 8 | 9 | 10 | 11 | 12 | 13 |

14 | 15 | ## Example 16 | 17 | https://imshaikot.github.io/srt-webvtt/ 18 | 19 | ## Installation 20 | 21 | ```bash 22 | $ npm install srt-webvtt --save 23 | ``` 24 | 25 | ## Getting Started 26 | 27 | Using it very easy but a little tricky indeed. 28 | To getting started: 29 | 30 | ```js 31 | // Using ES6 es-module 32 | import toWebVTT from "srt-webvtt"; // This is a default export, so you don't have to worry about the import name 33 | 34 | // Not using ES6?? 35 | var toWebVTT = require("srt-webvtt"); 36 | ``` 37 | 38 | ## Example and API 39 | 40 | When you're using `HTMLMediaElement` (example: `