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
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
15 deletions
+46
-15
common/lib/xmodule/xmodule/js/src/video/display.coffee
+2
-0
common/lib/xmodule/xmodule/js/src/video/display/video_player.coffee
+14
-10
common/lib/xmodule/xmodule/video_module.py
+27
-4
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
constructor
:
(
element
)
->
@
el
=
$
(
element
).
find
(
'.video'
)
@
id
=
@
el
.
attr
(
'id'
).
replace
(
/video_/
,
''
)
@
start
=
@
el
.
data
(
'start'
)
@
end
=
@
el
.
data
(
'end'
)
@
caption_data_dir
=
@
el
.
data
(
'caption-data-dir'
)
@
show_captions
=
@
el
.
data
(
'show-captions'
)
==
"true"
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
@
volumeControl
=
new
VideoVolumeControl
el
:
@
$
(
'.secondary-controls'
)
@
speedControl
=
new
VideoSpeedControl
el
:
@
$
(
'.secondary-controls'
),
speeds
:
@
video
.
speeds
,
currentSpeed
:
@
currentSpeed
()
@
progressSlider
=
new
VideoProgressSlider
el
:
@
$
(
'.slider'
)
@
debugger_1
@
playerVars
=
controls
:
0
wmode
:
'transparent'
rel
:
0
showinfo
:
0
enablejsapi
:
1
modestbranding
:
1
if
@
video
.
start
@
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
:
controls
:
0
wmode
:
'transparent'
rel
:
0
showinfo
:
0
enablejsapi
:
1
modestbranding
:
1
start
:
10
end
:
20
playerVars
:
@
playerVars
videoId
:
@
video
.
youtubeId
()
events
:
onReady
:
@
onReady
...
...
common/lib/xmodule/xmodule/video_module.py
View file @
97016d61
...
...
@@ -7,6 +7,9 @@ from pkg_resources import resource_string, resource_listdir
from
xmodule.x_module
import
XModule
from
xmodule.raw_module
import
RawDescriptor
import
datetime
import
time
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -33,6 +36,7 @@ class VideoModule(XModule):
self
.
show_captions
=
xmltree
.
get
(
'show_captions'
,
'true'
)
self
.
source
=
self
.
_get_source
(
xmltree
)
self
.
track
=
self
.
_get_track
(
xmltree
)
self
.
start_time
,
self
.
end_time
=
self
.
_get_timeframe
(
xmltree
)
if
instance_state
is
not
None
:
state
=
json
.
loads
(
instance_state
)
...
...
@@ -42,11 +46,11 @@ class VideoModule(XModule):
def
_get_source
(
self
,
xmltree
):
# find the first valid source
return
self
.
_get_first_external
(
xmltree
,
'source'
)
def
_get_track
(
self
,
xmltree
):
# find the first valid track
return
self
.
_get_first_external
(
xmltree
,
'track'
)
def
_get_first_external
(
self
,
xmltree
,
tag
):
"""
Will return the first valid element
...
...
@@ -61,6 +65,23 @@ class VideoModule(XModule):
break
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
):
'''
Handle ajax calls to this video.
...
...
@@ -98,11 +119,13 @@ class VideoModule(XModule):
'id'
:
self
.
location
.
html_id
(),
'position'
:
self
.
position
,
'source'
:
self
.
source
,
'track'
:
self
.
track
,
'track'
:
self
.
track
,
'display_name'
:
self
.
display_name
,
# TODO (cpennington): This won't work when we move to data that isn't on the filesystem
'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 @@
<h2>
${display_name}
</h2>
% 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"
>
<article
class=
"video-wrapper"
>
<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