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
df31b311
Commit
df31b311
authored
Feb 04, 2013
by
Valera Rozuvan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug when switching speeds in YouTube HTML5 player.
parent
baf6bbe3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
6 deletions
+31
-6
common/lib/xmodule/xmodule/js/src/videoalpha/display.coffee
+1
-1
common/lib/xmodule/xmodule/js/src/videoalpha/display/html5_video.js
+2
-1
common/lib/xmodule/xmodule/js/src/videoalpha/display/video_player.coffee
+23
-2
common/lib/xmodule/xmodule/js/src/videoalpha/display/video_speed_control.coffee
+5
-2
No files found.
common/lib/xmodule/xmodule/js/src/videoalpha/display.coffee
View file @
df31b311
...
@@ -15,7 +15,7 @@ class @VideoAlpha
...
@@ -15,7 +15,7 @@ class @VideoAlpha
else
else
@
videoType
=
"html5"
@
videoType
=
"html5"
@
parseVideoSources
@
el
.
data
(
'mp4-source'
),
@
el
.
data
(
'webm-source'
),
@
el
.
data
(
'ogg-source'
)
@
parseVideoSources
@
el
.
data
(
'mp4-source'
),
@
el
.
data
(
'webm-source'
),
@
el
.
data
(
'ogg-source'
)
@
speeds
=
[
'0.75'
,
'1.0'
,
'1.25'
,
'1.5'
]
@
speeds
=
[
'0.75'
,
'1.0'
,
'1.25'
,
'1.5
0
'
]
sub
=
@
el
.
data
(
'sub'
)
sub
=
@
el
.
data
(
'sub'
)
if
(
typeof
sub
isnt
"string"
)
or
(
sub
.
length
is
0
)
if
(
typeof
sub
isnt
"string"
)
or
(
sub
.
length
is
0
)
sub
=
""
sub
=
""
...
...
common/lib/xmodule/xmodule/js/src/videoalpha/display/html5_video.js
View file @
df31b311
...
@@ -194,6 +194,7 @@ this.HTML5Video = (function () {
...
@@ -194,6 +194,7 @@ this.HTML5Video = (function () {
// currently doing.
// currently doing.
this
.
video
=
this
.
videoEl
[
0
];
this
.
video
=
this
.
videoEl
[
0
];
this
.
playerState
=
HTML5Video
.
PlayerState
.
UNSTARTED
;
this
.
playerState
=
HTML5Video
.
PlayerState
.
UNSTARTED
;
// this.callStateChangeCallback();
// Attach a 'click' event on the <video> element. It will cause the video to pause/play.
// Attach a 'click' event on the <video> element. It will cause the video to pause/play.
this
.
videoEl
.
on
(
'click'
,
function
(
event
)
{
this
.
videoEl
.
on
(
'click'
,
function
(
event
)
{
...
@@ -227,7 +228,7 @@ this.HTML5Video = (function () {
...
@@ -227,7 +228,7 @@ this.HTML5Video = (function () {
_this
.
video
.
currentTime
=
_this
.
start
;
_this
.
video
.
currentTime
=
_this
.
start
;
if
(
$
.
isFunction
(
_this
.
config
.
events
.
onReady
)
===
true
)
{
if
(
$
.
isFunction
(
_this
.
config
.
events
.
onReady
)
===
true
)
{
_this
.
config
.
events
.
onReady
(
{}
);
_this
.
config
.
events
.
onReady
(
null
);
}
}
},
false
);
},
false
);
...
...
common/lib/xmodule/xmodule/js/src/videoalpha/display/video_player.coffee
View file @
df31b311
...
@@ -68,9 +68,14 @@ class @VideoPlayerAlpha extends SubviewAlpha
...
@@ -68,9 +68,14 @@ class @VideoPlayerAlpha extends SubviewAlpha
onReady
:
@
onReady
onReady
:
@
onReady
onStateChange
:
@
onStateChange
onStateChange
:
@
onStateChange
else
if
@
video
.
videoType
is
'youtube'
else
if
@
video
.
videoType
is
'youtube'
prev_player_type
=
$
.
cookie
(
'prev_player_type'
)
if
prev_player_type
==
'html5'
youTubeId
=
@
video
.
videos
[
'1.0'
]
else
youTubeId
=
@
video
.
youtubeId
()
@
player
=
new
YT
.
Player
@
video
.
id
,
@
player
=
new
YT
.
Player
@
video
.
id
,
playerVars
:
@
playerVars
playerVars
:
@
playerVars
videoId
:
@
video
.
youtubeId
()
videoId
:
youTubeId
events
:
events
:
onReady
:
@
onReady
onReady
:
@
onReady
onStateChange
:
@
onStateChange
onStateChange
:
@
onStateChange
...
@@ -85,6 +90,8 @@ class @VideoPlayerAlpha extends SubviewAlpha
...
@@ -85,6 +90,8 @@ class @VideoPlayerAlpha extends SubviewAlpha
at
:
'top center'
at
:
'top center'
onReady
:
(
event
)
=>
onReady
:
(
event
)
=>
if
@
video
.
videoType
is
'html5'
@
player
.
setPlaybackRate
@
video
.
speed
unless
onTouchBasedDevice
()
unless
onTouchBasedDevice
()
$
(
'.video-load-complete:first'
).
data
(
'video'
).
player
.
play
()
$
(
'.video-load-complete:first'
).
data
(
'video'
).
player
.
play
()
...
@@ -94,7 +101,14 @@ class @VideoPlayerAlpha extends SubviewAlpha
...
@@ -94,7 +101,14 @@ class @VideoPlayerAlpha extends SubviewAlpha
when
@
PlayerState
.
UNSTARTED
when
@
PlayerState
.
UNSTARTED
if
@
video
.
videoType
is
"youtube"
if
@
video
.
videoType
is
"youtube"
availableSpeeds
=
@
player
.
getAvailablePlaybackRates
()
availableSpeeds
=
@
player
.
getAvailablePlaybackRates
()
prev_player_type
=
$
.
cookie
(
'prev_player_type'
)
if
availableSpeeds
.
length
>
1
if
availableSpeeds
.
length
>
1
if
prev_player_type
==
'youtube'
$
.
cookie
(
'prev_player_type'
,
'html5'
,
expires
:
3650
,
path
:
'/'
)
@
onSpeedChange
null
,
'1.0'
else
if
prev_player_type
!=
'html5'
$
.
cookie
(
'prev_player_type'
,
'html5'
,
expires
:
3650
,
path
:
'/'
)
baseSpeedSubs
=
@
video
.
videos
[
"1.0"
]
baseSpeedSubs
=
@
video
.
videos
[
"1.0"
]
$
.
each
@
video
.
videos
,
(
index
,
value
)
->
$
.
each
@
video
.
videos
,
(
index
,
value
)
->
delete
_this
.
video
.
videos
[
index
]
delete
_this
.
video
.
videos
[
index
]
...
@@ -102,8 +116,15 @@ class @VideoPlayerAlpha extends SubviewAlpha
...
@@ -102,8 +116,15 @@ class @VideoPlayerAlpha extends SubviewAlpha
$
.
each
availableSpeeds
,
(
index
,
value
)
->
$
.
each
availableSpeeds
,
(
index
,
value
)
->
_this
.
video
.
videos
[
value
.
toFixed
(
2
).
replace
(
/\.00$/
,
".0"
)]
=
baseSpeedSubs
_this
.
video
.
videos
[
value
.
toFixed
(
2
).
replace
(
/\.00$/
,
".0"
)]
=
baseSpeedSubs
_this
.
video
.
speeds
.
push
value
.
toFixed
(
2
).
replace
(
/\.00$/
,
".0"
)
_this
.
video
.
speeds
.
push
value
.
toFixed
(
2
).
replace
(
/\.00$/
,
".0"
)
@
speedControl
.
reRender
@
video
.
speeds
@
speedControl
.
reRender
@
video
.
speeds
,
@
video
.
speed
@
video
.
videoType
=
'html5'
@
video
.
videoType
=
'html5'
@
video
.
setSpeed
$
.
cookie
(
'video_speed'
)
@
player
.
setPlaybackRate
@
video
.
speed
else
if
prev_player_type
!=
'youtube'
$
.
cookie
(
'prev_player_type'
,
'youtube'
,
expires
:
3650
,
path
:
'/'
)
@
onUnstarted
()
@
onUnstarted
()
when
@
PlayerState
.
PLAYING
when
@
PlayerState
.
PLAYING
@
onPlay
()
@
onPlay
()
...
...
common/lib/xmodule/xmodule/js/src/videoalpha/display/video_speed_control.coffee
View file @
df31b311
...
@@ -29,12 +29,15 @@ class @VideoSpeedControlAlpha extends SubviewAlpha
...
@@ -29,12 +29,15 @@ class @VideoSpeedControlAlpha extends SubviewAlpha
@
$
(
'.video_speeds'
).
prepend
(
$
(
'<li>'
).
attr
(
'data-speed'
,
speed
).
html
(
link
))
@
$
(
'.video_speeds'
).
prepend
(
$
(
'<li>'
).
attr
(
'data-speed'
,
speed
).
html
(
link
))
@
setSpeed
@
currentSpeed
@
setSpeed
@
currentSpeed
reRender
:
(
newSpeeds
)
->
reRender
:
(
newSpeeds
,
currentSpeed
)
->
@
$
(
'.video_speeds'
).
empty
()
@
$
(
'.video_speeds'
).
empty
()
@
$
(
'.video_speeds li'
).
removeClass
(
'active'
)
@
speeds
=
newSpeeds
@
speeds
=
newSpeeds
$
.
each
@
speeds
,
(
index
,
speed
)
=>
$
.
each
@
speeds
,
(
index
,
speed
)
=>
link
=
$
(
'<a>'
).
attr
(
href
:
"#"
).
html
(
"
#{
speed
}
x"
)
link
=
$
(
'<a>'
).
attr
(
href
:
"#"
).
html
(
"
#{
speed
}
x"
)
@
$
(
'.video_speeds'
).
prepend
(
$
(
'<li>'
).
attr
(
'data-speed'
,
speed
).
html
(
link
))
listItem
=
$
(
'<li>'
).
attr
(
'data-speed'
,
speed
).
html
(
link
);
listItem
.
addClass
(
'active'
)
if
speed
is
currentSpeed
@
$
(
'.video_speeds'
).
prepend
listItem
@
$
(
'.video_speeds a'
).
click
@
changeVideoSpeed
@
$
(
'.video_speeds a'
).
click
@
changeVideoSpeed
changeVideoSpeed
:
(
event
)
=>
changeVideoSpeed
:
(
event
)
=>
...
...
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