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
98ed7384
Commit
98ed7384
authored
Jun 13, 2012
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure we don't show volume control on iOS
parent
7924e5c8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
47 deletions
+73
-47
lms/static/coffee/spec/helper.coffee
+4
-3
lms/static/coffee/spec/modules/video/video_player_spec.coffee
+68
-43
lms/static/coffee/src/modules/video/video_player.coffee
+1
-1
No files found.
lms/static/coffee/spec/helper.coffee
View file @
98ed7384
...
@@ -33,14 +33,14 @@ jasmine.stubYoutubePlayer = ->
...
@@ -33,14 +33,14 @@ jasmine.stubYoutubePlayer = ->
'getCurrentTime'
,
'getPlayerState'
,
'getVolume'
,
'setVolume'
,
'loadVideoById'
,
'getCurrentTime'
,
'getPlayerState'
,
'getVolume'
,
'setVolume'
,
'loadVideoById'
,
'playVideo'
,
'pauseVideo'
,
'seekTo'
]
'playVideo'
,
'pauseVideo'
,
'seekTo'
]
jasmine
.
stubVideoPlayer
=
(
context
,
enableParts
)
->
jasmine
.
stubVideoPlayer
=
(
context
,
enableParts
,
createPlayer
=
true
)
->
enableParts
=
[
enableParts
]
unless
$
.
isArray
(
enableParts
)
enableParts
=
[
enableParts
]
unless
$
.
isArray
(
enableParts
)
suite
=
context
.
suite
suite
=
context
.
suite
currentPartName
=
suite
.
description
while
suite
=
suite
.
parentSuite
currentPartName
=
suite
.
description
while
suite
=
suite
.
parentSuite
enableParts
.
push
currentPartName
enableParts
.
push
currentPartName
for
part
in
[
'VideoCaption'
,
'VideoSpeedControl'
,
'VideoProgressSlider'
]
for
part
in
[
'VideoCaption'
,
'VideoSpeedControl'
,
'Video
VolumeControl'
,
'Video
ProgressSlider'
]
unless
$
.
inArray
(
part
,
enableParts
)
>=
0
unless
$
.
inArray
(
part
,
enableParts
)
>=
0
spyOn
window
,
part
spyOn
window
,
part
...
@@ -49,7 +49,8 @@ jasmine.stubVideoPlayer = (context, enableParts) ->
...
@@ -49,7 +49,8 @@ jasmine.stubVideoPlayer = (context, enableParts) ->
YT
.
Player
=
undefined
YT
.
Player
=
undefined
context
.
video
=
new
Video
'example'
,
'.75:abc123,1.0:def456'
context
.
video
=
new
Video
'example'
,
'.75:abc123,1.0:def456'
jasmine
.
stubYoutubePlayer
()
jasmine
.
stubYoutubePlayer
()
return
new
VideoPlayer
context
.
video
if
createPlayer
return
new
VideoPlayer
context
.
video
spyOn
(
window
,
'onunload'
)
spyOn
(
window
,
'onunload'
)
...
...
lms/static/coffee/spec/modules/video/video_player_spec.coffee
View file @
98ed7384
describe
'VideoPlayer'
,
->
describe
'VideoPlayer'
,
->
beforeEach
->
beforeEach
->
jasmine
.
stubVideoPlayer
@
jasmine
.
stubVideoPlayer
@
,
[],
false
afterEach
->
afterEach
->
YT
.
Player
=
undefined
YT
.
Player
=
undefined
...
@@ -11,69 +11,94 @@ describe 'VideoPlayer', ->
...
@@ -11,69 +11,94 @@ describe 'VideoPlayer', ->
spyOn
YT
,
'Player'
spyOn
YT
,
'Player'
$
.
fn
.
qtip
.
andCallFake
->
$
.
fn
.
qtip
.
andCallFake
->
$
(
this
).
data
(
'qtip'
,
true
)
$
(
this
).
data
(
'qtip'
,
true
)
$
(
'.video'
).
append
$
(
'<div class="hide-subtitles" />'
)
$
(
'.video'
).
append
$
(
'<div class="add-fullscreen" /><div class="hide-subtitles" />'
)
@
player
=
new
VideoPlayer
@
video
describe
'always'
,
->
beforeEach
->
@
player
=
new
VideoPlayer
@
video
it
'instanticate current time to zero'
,
->
it
'instanticate current time to zero'
,
->
expect
(
@
player
.
currentTime
).
toEqual
0
expect
(
@
player
.
currentTime
).
toEqual
0
it
'set the element'
,
->
it
'set the element'
,
->
expect
(
@
player
.
element
).
toBe
'#video_example'
expect
(
@
player
.
element
).
toBe
'#video_example'
it
'create video control'
,
->
it
'create video control'
,
->
expect
(
window
.
VideoControl
).
toHaveBeenCalledWith
@
player
expect
(
window
.
VideoControl
).
toHaveBeenCalledWith
@
player
it
'create video caption'
,
->
it
'create video caption'
,
->
expect
(
window
.
VideoCaption
).
toHaveBeenCalledWith
@
player
,
'def456'
expect
(
window
.
VideoCaption
).
toHaveBeenCalledWith
@
player
,
'def456'
it
'create video speed control'
,
->
it
'create video speed control'
,
->
expect
(
window
.
VideoSpeedControl
).
toHaveBeenCalledWith
@
player
,
[
'0.75'
,
'1.0'
]
expect
(
window
.
VideoSpeedControl
).
toHaveBeenCalledWith
@
player
,
[
'0.75'
,
'1.0'
]
it
'create video progress slider'
,
->
it
'create video progress slider'
,
->
expect
(
window
.
VideoProgressSlider
).
toHaveBeenCalledWith
@
player
expect
(
window
.
VideoProgressSlider
).
toHaveBeenCalledWith
@
player
it
'create Youtube player'
,
->
it
'create Youtube player'
,
->
expect
(
YT
.
Player
).
toHaveBeenCalledWith
'example'
expect
(
YT
.
Player
).
toHaveBeenCalledWith
'example'
playerVars
:
playerVars
:
controls
:
0
controls
:
0
wmode
:
'transparent'
wmode
:
'transparent'
rel
:
0
rel
:
0
showinfo
:
0
showinfo
:
0
enablejsapi
:
1
enablejsapi
:
1
videoId
:
'def456'
videoId
:
'def456'
events
:
events
:
onReady
:
@
player
.
onReady
onReady
:
@
player
.
onReady
onStateChange
:
@
player
.
onStateChange
onStateChange
:
@
player
.
onStateChange
it
'bind to seek event'
,
->
it
'bind to seek event'
,
->
expect
(
$
(
@
player
)).
toHandleWith
'seek'
,
@
player
.
onSeek
expect
(
$
(
@
player
)).
toHandleWith
'seek'
,
@
player
.
onSeek
it
'bind to updatePlayTime event'
,
->
it
'bind to updatePlayTime event'
,
->
expect
(
$
(
@
player
)).
toHandleWith
'updatePlayTime'
,
@
player
.
onUpdatePlayTime
expect
(
$
(
@
player
)).
toHandleWith
'updatePlayTime'
,
@
player
.
onUpdatePlayTime
it
'bidn to speedChange event'
,
->
it
'bidn to speedChange event'
,
->
expect
(
$
(
@
player
)).
toHandleWith
'speedChange'
,
@
player
.
onSpeedChange
expect
(
$
(
@
player
)).
toHandleWith
'speedChange'
,
@
player
.
onSpeedChange
it
'bind to play event'
,
->
it
'bind to play event'
,
->
expect
(
$
(
@
player
)).
toHandleWith
'play'
,
@
player
.
onPlay
expect
(
$
(
@
player
)).
toHandleWith
'play'
,
@
player
.
onPlay
it
'bind to paused event'
,
->
it
'bind to paused event'
,
->
expect
(
$
(
@
player
)).
toHandleWith
'pause'
,
@
player
.
onPause
expect
(
$
(
@
player
)).
toHandleWith
'pause'
,
@
player
.
onPause
it
'bind to ended event'
,
->
it
'bind to ended event'
,
->
expect
(
$
(
@
player
)).
toHandleWith
'ended'
,
@
player
.
onPause
expect
(
$
(
@
player
)).
toHandleWith
'ended'
,
@
player
.
onPause
it
'bind to key press'
,
->
it
'bind to key press'
,
->
expect
(
$
(
document
)).
toHandleWith
'keyup'
,
@
player
.
bindExitFullScreen
expect
(
$
(
document
)).
toHandleWith
'keyup'
,
@
player
.
bindExitFullScreen
it
'bind to fullscreen switching button'
,
->
it
'bind to fullscreen switching button'
,
->
expect
(
$
(
'.add-fullscreen'
)).
toHandleWith
'click'
,
@
player
.
toggleFullScreen
console
.
debug
$
(
'.add-fullscreen'
)
expect
(
$
(
'.add-fullscreen'
)).
toHandleWith
'click'
,
@
player
.
toggleFullScreen
describe
'when not on a touch based device'
,
->
describe
'when not on a touch based device'
,
->
beforeEach
->
spyOn
(
window
,
'onTouchBasedDevice'
).
andReturn
false
$
(
'.add-fullscreen, .hide-subtitles'
).
removeData
'qtip'
@
player
=
new
VideoPlayer
@
video
it
'add the tooltip to fullscreen and subtitle button'
,
->
it
'add the tooltip to fullscreen and subtitle button'
,
->
expect
(
$
(
'.add-fullscreen'
)).
toHaveData
'qtip'
expect
(
$
(
'.add-fullscreen'
)).
toHaveData
'qtip'
expect
(
$
(
'.hide-subtitles'
)).
toHaveData
'qtip'
expect
(
$
(
'.hide-subtitles'
)).
toHaveData
'qtip'
it
'create video volume control'
,
->
expect
(
window
.
VideoVolumeControl
).
toHaveBeenCalledWith
@
player
describe
'when on a touch based device'
,
->
beforeEach
->
spyOn
(
window
,
'onTouchBasedDevice'
).
andReturn
true
$
(
'.add-fullscreen, .hide-subtitles'
).
removeData
'qtip'
@
player
=
new
VideoPlayer
@
video
it
'does not add the tooltip to fullscreen and subtitle button'
,
->
expect
(
$
(
'.add-fullscreen'
)).
not
.
toHaveData
'qtip'
expect
(
$
(
'.hide-subtitles'
)).
not
.
toHaveData
'qtip'
it
'does not create video volume control'
,
->
expect
(
window
.
VideoVolumeControl
).
not
.
toHaveBeenCalled
()
describe
'onReady'
,
->
describe
'onReady'
,
->
beforeEach
->
beforeEach
->
@
video
.
embed
()
@
video
.
embed
()
...
...
lms/static/coffee/src/modules/video/video_player.coffee
View file @
98ed7384
...
@@ -30,7 +30,7 @@ class @VideoPlayer
...
@@ -30,7 +30,7 @@ class @VideoPlayer
render
:
->
render
:
->
new
VideoControl
@
new
VideoControl
@
new
VideoCaption
@
,
@
video
.
youtubeId
(
'1.0'
)
new
VideoCaption
@
,
@
video
.
youtubeId
(
'1.0'
)
new
VideoVolumeControl
@
new
VideoVolumeControl
@
unless
onTouchBasedDevice
()
new
VideoSpeedControl
@
,
@
video
.
speeds
new
VideoSpeedControl
@
,
@
video
.
speeds
new
VideoProgressSlider
@
new
VideoProgressSlider
@
@
player
=
new
YT
.
Player
@
video
.
id
,
@
player
=
new
YT
.
Player
@
video
.
id
,
...
...
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