-
Notifications
You must be signed in to change notification settings - Fork 20
Add support for Dash.js rendered subtitles #352
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
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
dd29347
Feat: Support MSE Subtitles for Low Latency
ryanmccartney f9b1227
Add tests for new subtitle type
ryanmccartney 80d4851
Subtitles: low-latency docs
ryanmccartney 0d68c69
Subtitles: low-latency docs
ryanmccartney 033bcc3
Merge branch 'master' of https://github.com/ryanmccartney/bigscreen-p…
ryanmccartney 6279f29
Don't require a captions object when dashSubtitles override is used
ryanmccartney db5e2d6
Add tests for DashSubtitles
ryanmccartney 40d95d8
Merge branch 'bbc:master' into dash-subtitles
ryanmccartney 3f65696
Rename DashSubs to EmbeddedSubs
ryanmccartney 2e5d782
Merge branch 'master' into dash-subtitles
tom-coward 4c6edf7
Fix merge (missing })
tom-coward 485ca68
Wait for media player to be ready before enabling embedded subtitles
tom-coward 591a553
Pass IMSCjs style options through BSP to embeddedsubtitles
ryanmccartney 56c8386
Add customisation to embedded subtitles
ryanmccartney d6b0cc1
Merge branch 'master' of https://github.com/bbc/bigscreen-player into…
ryanmccartney 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
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,90 @@ | ||
import DOMHelpers from "../domhelpers" | ||
import Utils from "../utils/playbackutils" | ||
|
||
function EmbeddedSubtitles(mediaPlayer, autoStart, parentElement, mediaSources, defaultStyleOpts) { | ||
let currentSubtitlesElement | ||
|
||
let imscRenderOpts = transformStyleOptions(defaultStyleOpts) | ||
|
||
if (autoStart) { | ||
start() | ||
mediaPlayer.addEventCallback(this, onMediaPlayerReady) | ||
} | ||
|
||
function onMediaPlayerReady() { | ||
mediaPlayer.removeEventCallback(this, onMediaPlayerReady) | ||
} | ||
|
||
function removeCurrentSubtitlesElement() { | ||
if (currentSubtitlesElement) { | ||
DOMHelpers.safeRemoveElement(currentSubtitlesElement) | ||
currentSubtitlesElement = undefined | ||
} | ||
} | ||
|
||
function addCurrentSubtitlesElement() { | ||
removeCurrentSubtitlesElement() | ||
currentSubtitlesElement = document.createElement("div") | ||
currentSubtitlesElement.id = "bsp_subtitles" | ||
currentSubtitlesElement.style.position = "absolute" | ||
parentElement.appendChild(currentSubtitlesElement) | ||
} | ||
|
||
function start() { | ||
mediaPlayer.setSubtitles(true) | ||
customise(imscRenderOpts) | ||
if (!currentSubtitlesElement) { | ||
addCurrentSubtitlesElement() | ||
} | ||
} | ||
|
||
function stop() { | ||
mediaPlayer.setSubtitles(false) | ||
} | ||
|
||
function tearDown() { | ||
stop() | ||
} | ||
|
||
function customise(styleOpts) { | ||
const customStyleOptions = transformStyleOptions(styleOpts) | ||
imscRenderOpts = Utils.merge(imscRenderOpts, customStyleOptions) | ||
mediaPlayer.customiseSubtitles(imscRenderOpts) | ||
} | ||
|
||
// Opts: { backgroundColour: string (css colour, hex), fontFamily: string , size: number, lineHeight: number } | ||
function transformStyleOptions(opts) { | ||
if (opts === undefined) return | ||
|
||
const customStyles = {} | ||
|
||
if (opts.backgroundColour) { | ||
customStyles.spanBackgroundColorAdjust = { transparent: opts.backgroundColour } | ||
} | ||
|
||
if (opts.fontFamily) { | ||
customStyles.fontFamily = opts.fontFamily | ||
} | ||
|
||
if (opts.size > 0) { | ||
customStyles.sizeAdjust = opts.size | ||
} | ||
|
||
if (opts.lineHeight) { | ||
customStyles.lineHeightAdjust = opts.lineHeight | ||
} | ||
|
||
return customStyles | ||
} | ||
|
||
addCurrentSubtitlesElement() | ||
|
||
return { | ||
start, | ||
stop, | ||
customise, | ||
tearDown, | ||
} | ||
} | ||
|
||
export default EmbeddedSubtitles |
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.