Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
Hsin-Yu Chien
edx-platform-release
Commits
aa063d57
Commit
aa063d57
authored
12 years ago
by
Carlos Andrés Rocha
Browse files
Options
Downloads
Patches
Plain Diff
[#35065403] Lets video player continue to work if subtitles cannot be loaded
parent
bf6fe102
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/lib/xmodule/xmodule/js/src/video/display/video_caption.coffee
+33
-25
33 additions, 25 deletions
...xmodule/xmodule/js/src/video/display/video_caption.coffee
with
33 additions
and
25 deletions
common/lib/xmodule/xmodule/js/src/video/display/video_caption.coffee
+
33
−
25
View file @
aa063d57
class
@
VideoCaption
extends
Subview
initialize
:
->
@
loaded
=
false
bind
:
->
$
(
window
).
bind
(
'resize'
,
@
resize
)
@
$
(
'.hide-subtitles'
).
click
@
toggle
...
...
@@ -24,6 +27,8 @@ class @VideoCaption extends Subview
@
captions
=
captions
.
text
@
start
=
captions
.
start
@
loaded
=
true
if
onTouchBasedDevice
()
$
(
'.subtitles li'
).
html
"Caption will be displayed when you start playing the video."
else
...
...
@@ -47,37 +52,40 @@ class @VideoCaption extends Subview
@
rendered
=
true
search
:
(
time
)
->
min
=
0
max
=
@
start
.
length
-
1
while
min
<
max
index
=
Math
.
ceil
((
max
+
min
)
/
2
)
if
time
<
@
start
[
index
]
max
=
index
-
1
if
time
>=
@
start
[
index
]
min
=
index
return
min
if
@
loaded
min
=
0
max
=
@
start
.
length
-
1
while
min
<
max
index
=
Math
.
ceil
((
max
+
min
)
/
2
)
if
time
<
@
start
[
index
]
max
=
index
-
1
if
time
>=
@
start
[
index
]
min
=
index
return
min
play
:
->
@
renderCaption
()
unless
@
rendered
@
playing
=
true
if
@
loaded
@
renderCaption
()
unless
@
rendered
@
playing
=
true
pause
:
->
@
playing
=
false
if
@
loaded
@
playing
=
false
updatePlayTime
:
(
time
)
->
# This 250ms offset is required to match the video speed
time
=
Math
.
round
(
Time
.
convert
(
time
,
@
currentSpeed
,
'1.0'
)
*
1000
+
250
)
newIndex
=
@
search
time
if
newIndex
!=
undefined
&&
@
currentIndex
!=
newIndex
if
@
currentIndex
@
$
(
".subtitles li.current"
).
removeClass
(
'current'
)
@
$
(
".subtitles li[data-index='
#{
newIndex
}
']"
).
addClass
(
'current'
)
@
currentIndex
=
newIndex
@
scrollCaption
()
if
@
loaded
# This 250ms offset is required to match the video speed
time
=
Math
.
round
(
Time
.
convert
(
time
,
@
currentSpeed
,
'1.0'
)
*
1000
+
250
)
newIndex
=
@
search
time
if
newIndex
!=
undefined
&&
@
currentIndex
!=
newIndex
if
@
currentIndex
@
$
(
".subtitles li.current"
).
removeClass
(
'current'
)
@
$
(
".subtitles li[data-index='
#{
newIndex
}
']"
).
addClass
(
'current'
)
@
currentIndex
=
newIndex
@
scrollCaption
()
resize
:
=>
@
$
(
'.subtitles'
).
css
maxHeight
:
@
captionHeight
()
...
...
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