-
Notifications
You must be signed in to change notification settings - Fork 7
Added subtitles plugin #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gvamshi-metrological
wants to merge
18
commits into
Metrological:master
Choose a base branch
from
gvamshi-metrological:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
afcbbaa
Added subtitles plugin
gvamshi-metrological ccc62f6
Addressed code review comments
gvamshi-metrological 9a52ced
Integrated subtitles into videoPlayer
gvamshi-metrological 22fca8c
Merge branch 'Metrological:master' into master
gvamshi-metrological 2cc68a7
Merge branch 'master' of github.com:gvamshi-metrological/metrological…
gvamshi-metrological 5d49f22
Create test.yml
gvamshi-metrological 4f89744
Adding git hub actions to master
gvamshi-metrological b235980
Merge branch 'master' of github.com:gvamshi-metrological/metrological…
gvamshi-metrological a113ab8
Integrated subtitles into videoPlayer (#1)
gvamshi-metrological b095094
Removed unused testURl in jest.config
gvamshi-metrological be698d7
Fixed subtitle plugin issues
gvamshi-metrological 99e2730
Addressed review comments
gvamshi-metrological fcaa26c
Addressed review comments (#2)
gvamshi-metrological 3b77e58
Renamed subtitles as subtitlesParser
gvamshi-metrological b7b79ec
Handling empty subtitles
gvamshi-metrological e751fd8
Addressed code review comments
gvamshi-metrological 191d353
Addressed code review comments
gvamshi-metrological a8449ee
updated docs and removed comments
gvamshi-metrological File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| node_modules | ||
| .DS_store | ||
| .idea | ||
| coverage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| module.exports = { | ||
| env: { | ||
| test: { | ||
| plugins: ['@babel/plugin-transform-modules-commonjs'], | ||
| }, | ||
| }, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # SubtitlesParser | ||
|
|
||
| subtitle plugin allows you to fetch and parse the subtitle file from the given URL and you can read the subtitle text from the parsed file based on the current videoplayback time. | ||
|
|
||
| ## Usage | ||
|
|
||
| If you want to access SubtitlesParser in your App code directly, import the *SubtitlesParser* plugin from the Lightning SDK: | ||
|
|
||
| ```js | ||
| import { SubtitlesParser } from '@lightningjs/sdk' | ||
| ``` | ||
|
|
||
|
|
||
| ## Available methods | ||
|
|
||
| ### fetchAndParseSubs | ||
|
|
||
| `fetchAndParseSubs` method expects a valid file URL as an argument. | ||
| This method will fetch a file from the URL and parse it to create a list of objects. created subtitles list is stored in the plugin. | ||
| This method returns a promise that resolves to parsed subtitles as a list of objects containing {start, end, payload}. | ||
| ```js | ||
| const subtitlesUrl = 'http://abc.def.com/xyz.srt' | ||
| SubtitlesParser.fetchAndParseSubs(subtitlesUrl) | ||
| ``` | ||
| ### customParser | ||
|
|
||
| Default parser in subtitle plugin can parse .srt and .vvt files. If you don't want to use the default parser you can also send a customParser as a callback to `fetchAndParseSubs` as a second argument, customParser should return a list of subtitle objects that contains | ||
| {start: <float>, end: <float>, payload: <string>} | ||
|
|
||
|
|
||
| ```js | ||
| const customParser = (str) = { | ||
| ... | ||
| ... | ||
| return [{start: 3, end: 10, payload: 'this is subtitle text'}, { start: 11, end: 14, payload: 'this is subtitle text2'}, ...] | ||
| } | ||
| const subtitlesUrl = 'http://abc.def.com/xyz.srt' | ||
| SubtitlesParser.fetchAndParseSubs(subtitlesUrl, customParser) | ||
| ``` | ||
|
|
||
| ### removeSubtitleTextStyles | ||
|
|
||
| By default, all the TextStyles in the subtitle string are removed, you can pass {removeSubtitleTextStyles: false} as | ||
| the third argument to keep text styles in subtitle string | ||
|
|
||
| ```js | ||
| SubtitlesParser.fetchAndParseSubs(URL, null, {removeSubtitleTextStyles: false}) | ||
| ``` | ||
| ### getSubtitleByTimeIndex | ||
| From the stored subtitles you can get subtitles as text when you pass currentTime(in seconds) as an argument to the method. | ||
|
|
||
| ```js | ||
| SubtitlesParser.getSubtitleByTimeIndex(currentTime) | ||
| ``` | ||
|
|
||
| ### clearCurrentSubtitle | ||
|
|
||
| `clearCurrentSubtitle` method will clear all the stored subtitles in the plugin. | ||
|
|
||
| ```js | ||
| SubtitlesParser.clearCurrentSubtitle() | ||
| ``` | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /* | ||
| * For a detailed explanation regarding each configuration property, visit: | ||
| * https://jestjs.io/docs/configuration | ||
| */ | ||
|
|
||
| module.exports = { | ||
| clearMocks: true, | ||
| collectCoverage: true, | ||
| coverageDirectory: 'coverage', | ||
| coverageProvider: 'v8', | ||
| coverageThreshold: { | ||
| global: { | ||
| lines: 70, | ||
| }, | ||
| }, | ||
| testEnvironment: 'jsdom', | ||
| testEnvironmentOptions: { resources: 'usable' }, | ||
| moduleNameMapper: { | ||
| '@/(.*)$': '<rootDir>/src/$1', | ||
| '^src(.*)': '<rootDir>/src$1', | ||
| '^test(.*)': '<rootDir>/test$1', | ||
| }, | ||
| transform: { '^.+\\.[m|t]?js$': 'babel-jest' }, | ||
| transformIgnorePatterns: [], | ||
| verbose: true, | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.