-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
54 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,15 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
import videojs from 'video.js'; | ||
|
||
// This is tightly coupled to VideoJS's tracks implementation, because VideoJS removes the tracks from the | ||
// native player when it initializes. This depends on the media_tag_controller.js emitting a custom media-loaded | ||
// event. The load method on this class is called when that happens, and draws the transcript. | ||
export default class extends Controller { | ||
static targets = [ ] | ||
|
||
load(evt) { | ||
const track = evt.detail.textTracks_.tracks_.find((track) => track.kind === 'captions' ) | ||
const cues = track.cues.cues_.map((cue) => `<p class="cue" data-cue-id="${cue.id}" data-cue-start-time="${cue.startTime}" data-cue-end-time="${cue.endTime}">${cue.text}</p>`) | ||
this.element.innerHTML = cues.join('') | ||
} | ||
} |