Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BRIC
dokuwiki
Commits
345058f7
Unverified
Commit
345058f7
authored
7 years ago
by
Andreas Gohr
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #2077 from schplurtz/vtt-tracks
Support Web Video Text Tracks Format subtitles
parents
680cee63
23c61bbe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
conf/mime.conf
+1
-0
1 addition, 0 deletions
conf/mime.conf
inc/media.php
+35
-0
35 additions, 0 deletions
inc/media.php
inc/parser/xhtml.php
+11
-0
11 additions, 0 deletions
inc/parser/xhtml.php
with
47 additions
and
0 deletions
conf/mime.conf
+
1
−
0
View file @
345058f7
...
...
@@ -15,6 +15,7 @@ wav audio/wav
webm
video
/
webm
ogv
video
/
ogg
mp4
video
/
mp4
vtt
text
/
vtt
tgz
!
application
/
octet
-
stream
tar
!
application
/
x
-
gtar
...
...
This diff is collapsed.
Click to expand it.
inc/media.php
+
35
−
0
View file @
345058f7
...
...
@@ -2460,4 +2460,39 @@ function media_supportedav($mime, $type=NULL){
return
in_array
(
$mime
,
$supportedAv
);
}
/**
* Return track media files with the same base name
* but extensions that indicate kind and lang.
* ie for foo.webm search foo.sub.lang.vtt, foo.cap.lang.vtt...
*
* @param string $src - ID of media file
* @return array - array(mediaID => array( kind, srclang ))
*
* @author Schplurtz le Déboulonné <Schplurtz@laposte.net>
*/
function
media_trackfiles
(
$src
){
$kinds
=
array
(
'sub'
=>
'subtitles'
,
'cap'
=>
'captions'
,
'des'
=>
'descriptions'
,
'cha'
=>
'chapters'
,
'met'
=>
'metadata'
);
$files
=
array
();
$re
=
'/\\.(sub|cap|des|cha|met)\\.([^.]+)\\.vtt$/'
;
$baseid
=
pathinfo
(
$src
,
PATHINFO_FILENAME
);
$pattern
=
mediaFN
(
$baseid
)
.
'.*.*.vtt'
;
$list
=
glob
(
$pattern
);
foreach
(
$list
as
$track
)
{
if
(
preg_match
(
$re
,
$track
,
$matches
)){
$files
[
$baseid
.
'.'
.
$matches
[
1
]
.
'.'
.
$matches
[
2
]
.
'.vtt'
]
=
array
(
$kinds
[
$matches
[
1
]],
$matches
[
2
],
);
}
}
return
$files
;
}
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
This diff is collapsed.
Click to expand it.
inc/parser/xhtml.php
+
11
−
0
View file @
345058f7
...
...
@@ -1783,6 +1783,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
* Embed video(s) in HTML
*
* @author Anika Henke <anika@selfthinker.org>
* @author Schplurtz le Déboulonné <Schplurtz@laposte.net>
*
* @param string $src - ID of video to embed
* @param int $width - width of the video in pixels
...
...
@@ -1800,6 +1801,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$posterUrl
=
''
;
$files
=
array
();
$tracks
=
array
();
$isExternal
=
media_isexternal
(
$src
);
if
(
$isExternal
)
{
...
...
@@ -1811,6 +1813,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$extensions
=
array
(
'webm'
,
'ogv'
,
'mp4'
);
$files
=
media_alternativefiles
(
$src
,
$extensions
);
$poster
=
media_alternativefiles
(
$src
,
array
(
'jpg'
,
'png'
));
$tracks
=
media_trackfiles
(
$src
);
if
(
!
empty
(
$poster
))
{
$posterUrl
=
ml
(
reset
(
$poster
),
''
,
true
,
'&'
);
}
...
...
@@ -1839,6 +1842,14 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$fallback
.
=
$this
->
$linkType
(
$file
,
$title
,
null
,
null
,
null
,
$cache
=
null
,
$linking
=
'linkonly'
,
$return
=
true
);
}
// output each track if any
foreach
(
$tracks
as
$trackid
=>
$info
)
{
list
(
$kind
,
$srclang
)
=
array_map
(
'hsc'
,
$info
);
$out
.
=
"<track kind=
\"
$kind
\"
srclang=
\"
$srclang
\"
"
;
$out
.
=
"label=
\"
$srclang
\"
"
;
$out
.
=
'src="'
.
ml
(
$trackid
,
''
,
true
)
.
'">'
.
NL
;
}
// finish
$out
.
=
$fallback
;
$out
.
=
'</video>'
.
NL
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment