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
97016d61
Commit
97016d61
authored
Dec 05, 2012
by
Alexander Kryklia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
video time frame support for xmodule
parent
73900157
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
8 deletions
+39
-8
common/lib/xmodule/xmodule/js/src/video/display.coffee
+2
-0
common/lib/xmodule/xmodule/js/src/video/display/video_player.coffee
+9
-5
common/lib/xmodule/xmodule/video_module.py
+25
-2
lms/templates/video.html
+3
-1
No files found.
common/lib/xmodule/xmodule/js/src/video/display.coffee
View file @
97016d61
...
@@ -2,6 +2,8 @@ class @Video
...
@@ -2,6 +2,8 @@ class @Video
constructor
:
(
element
)
->
constructor
:
(
element
)
->
@
el
=
$
(
element
).
find
(
'.video'
)
@
el
=
$
(
element
).
find
(
'.video'
)
@
id
=
@
el
.
attr
(
'id'
).
replace
(
/video_/
,
''
)
@
id
=
@
el
.
attr
(
'id'
).
replace
(
/video_/
,
''
)
@
start
=
@
el
.
data
(
'start'
)
@
end
=
@
el
.
data
(
'end'
)
@
caption_data_dir
=
@
el
.
data
(
'caption-data-dir'
)
@
caption_data_dir
=
@
el
.
data
(
'caption-data-dir'
)
@
show_captions
=
@
el
.
data
(
'show-captions'
)
==
"true"
@
show_captions
=
@
el
.
data
(
'show-captions'
)
==
"true"
window
.
player
=
null
window
.
player
=
null
...
...
common/lib/xmodule/xmodule/js/src/video/display/video_player.coffee
View file @
97016d61
...
@@ -36,17 +36,21 @@ class @VideoPlayer extends Subview
...
@@ -36,17 +36,21 @@ class @VideoPlayer extends Subview
@
volumeControl
=
new
VideoVolumeControl
el
:
@
$
(
'.secondary-controls'
)
@
volumeControl
=
new
VideoVolumeControl
el
:
@
$
(
'.secondary-controls'
)
@
speedControl
=
new
VideoSpeedControl
el
:
@
$
(
'.secondary-controls'
),
speeds
:
@
video
.
speeds
,
currentSpeed
:
@
currentSpeed
()
@
speedControl
=
new
VideoSpeedControl
el
:
@
$
(
'.secondary-controls'
),
speeds
:
@
video
.
speeds
,
currentSpeed
:
@
currentSpeed
()
@
progressSlider
=
new
VideoProgressSlider
el
:
@
$
(
'.slider'
)
@
progressSlider
=
new
VideoProgressSlider
el
:
@
$
(
'.slider'
)
@
debugger_1
@
playerVars
=
@
player
=
new
YT
.
Player
@
video
.
id
,
playerVars
:
controls
:
0
controls
:
0
wmode
:
'transparent'
wmode
:
'transparent'
rel
:
0
rel
:
0
showinfo
:
0
showinfo
:
0
enablejsapi
:
1
enablejsapi
:
1
modestbranding
:
1
modestbranding
:
1
start
:
10
if
@
video
.
start
end
:
20
@
playerVars
.
start
=
@
video
.
start
if
@
video
.
end
# work in AS3, not HMLT5. but iframe use AS3
@
playerVars
.
end
=
@
video
.
end
@
player
=
new
YT
.
Player
@
video
.
id
,
playerVars
:
@
playerVars
videoId
:
@
video
.
youtubeId
()
videoId
:
@
video
.
youtubeId
()
events
:
events
:
onReady
:
@
onReady
onReady
:
@
onReady
...
...
common/lib/xmodule/xmodule/video_module.py
View file @
97016d61
...
@@ -7,6 +7,9 @@ from pkg_resources import resource_string, resource_listdir
...
@@ -7,6 +7,9 @@ from pkg_resources import resource_string, resource_listdir
from
xmodule.x_module
import
XModule
from
xmodule.x_module
import
XModule
from
xmodule.raw_module
import
RawDescriptor
from
xmodule.raw_module
import
RawDescriptor
import
datetime
import
time
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
...
@@ -33,6 +36,7 @@ class VideoModule(XModule):
...
@@ -33,6 +36,7 @@ class VideoModule(XModule):
self
.
show_captions
=
xmltree
.
get
(
'show_captions'
,
'true'
)
self
.
show_captions
=
xmltree
.
get
(
'show_captions'
,
'true'
)
self
.
source
=
self
.
_get_source
(
xmltree
)
self
.
source
=
self
.
_get_source
(
xmltree
)
self
.
track
=
self
.
_get_track
(
xmltree
)
self
.
track
=
self
.
_get_track
(
xmltree
)
self
.
start_time
,
self
.
end_time
=
self
.
_get_timeframe
(
xmltree
)
if
instance_state
is
not
None
:
if
instance_state
is
not
None
:
state
=
json
.
loads
(
instance_state
)
state
=
json
.
loads
(
instance_state
)
...
@@ -61,6 +65,23 @@ class VideoModule(XModule):
...
@@ -61,6 +65,23 @@ class VideoModule(XModule):
break
break
return
result
return
result
def
_get_timeframe
(
self
,
xmltree
):
""" Converts 'from' and 'to' parameters in video tag to seconds.
If there are no parameters, returns empty string. """
def
parse_time
(
s
):
"""Converts s in '12:34:45' format to seconds. If s is
None, returns empty string"""
if
s
is
None
:
return
''
else
:
x
=
time
.
strptime
(
s
,
'
%
H:
%
M:
%
S'
)
return
datetime
.
timedelta
(
hours
=
x
.
tm_hour
,
minutes
=
x
.
tm_min
,
seconds
=
x
.
tm_sec
)
.
total_seconds
()
return
parse_time
(
xmltree
.
get
(
'from'
)),
parse_time
(
xmltree
.
get
(
'to'
))
def
handle_ajax
(
self
,
dispatch
,
get
):
def
handle_ajax
(
self
,
dispatch
,
get
):
'''
'''
Handle ajax calls to this video.
Handle ajax calls to this video.
...
@@ -98,11 +119,13 @@ class VideoModule(XModule):
...
@@ -98,11 +119,13 @@ class VideoModule(XModule):
'id'
:
self
.
location
.
html_id
(),
'id'
:
self
.
location
.
html_id
(),
'position'
:
self
.
position
,
'position'
:
self
.
position
,
'source'
:
self
.
source
,
'source'
:
self
.
source
,
'track'
:
self
.
track
,
'track'
:
self
.
track
,
'display_name'
:
self
.
display_name
,
'display_name'
:
self
.
display_name
,
# TODO (cpennington): This won't work when we move to data that isn't on the filesystem
# TODO (cpennington): This won't work when we move to data that isn't on the filesystem
'data_dir'
:
self
.
metadata
[
'data_dir'
],
'data_dir'
:
self
.
metadata
[
'data_dir'
],
'show_captions'
:
self
.
show_captions
'show_captions'
:
self
.
show_captions
,
'start'
:
self
.
start_time
,
'end'
:
self
.
end_time
})
})
...
...
lms/templates/video.html
View file @
97016d61
...
@@ -2,7 +2,9 @@
...
@@ -2,7 +2,9 @@
<h2>
${display_name}
</h2>
<h2>
${display_name}
</h2>
% endif
% endif
<div
id=
"video_${id}"
class=
"video"
data-streams=
"${streams}"
data-caption-data-dir=
"${data_dir}"
data-show-captions=
"${show_captions}"
>
<div
id=
"video_${id}"
class=
"video"
data-streams=
"${streams}"
data-caption-data-dir=
"${data_dir}"
data-show-captions=
"${show_captions}"
data-start=
"${start}"
data-end=
"${end}"
>
<div
class=
"tc-wrapper"
>
<div
class=
"tc-wrapper"
>
<article
class=
"video-wrapper"
>
<article
class=
"video-wrapper"
>
<section
class=
"video-player"
>
<section
class=
"video-player"
>
...
...
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