Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
aa063d57
Commit
aa063d57
authored
Aug 28, 2012
by
Carlos Andrés Rocha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[#35065403] Lets video player continue to work if subtitles cannot be loaded
parent
bf6fe102
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
25 deletions
+33
-25
common/lib/xmodule/xmodule/js/src/video/display/video_caption.coffee
+33
-25
No files found.
common/lib/xmodule/xmodule/js/src/video/display/video_caption.coffee
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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment