Skip to content
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

Add support for video captions #915

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Symplify the code using async/await and array maps
Signed-off-by: Frederic Ruget <fred@atlant.is>
douzebis authored and CarlSchwan committed Sep 1, 2022
commit b0ccf506278471fbee65c2a9555528abf2b3ad86
30 changes: 15 additions & 15 deletions src/components/Videos.vue
Original file line number Diff line number Diff line change
@@ -150,22 +150,22 @@ export default {
},

// Fetch caption tracks and build HTML5 block
fetchTracks() {
const url = generateUrl('/apps/viewer/video/tracks')
const params = { params: { videoPath: this.filename } }
axios.get(url, params).then(response => {
async fetchTracks() {
try {
const response = await axios.get(
generateUrl('/apps/viewer/video/tracks'),
{ params: { videoPath: this.filename } }
)
const davDir = this.davPath.replace(/[^/]*$/, '')
const tracks = response.data
const capTracks = []
for (const track of tracks) {
capTracks.push({
davPath: davDir + track.basename,
language: track.language,
locale: track.locale,
})
}
this.tracks = capTracks
})
this.tracks = response.data.map(track => ({
davPath: davDir + track.basename,
language: track.language,
locale: track.locale,
}))
} catch (error) {
console.error('Unable to fetch subtitles', error)
this.tracks = []
}
},

donePlaying() {