Commit f8943b1a by Prem Sichanugrist Committed by Matthew Mongeau

Make sure we don't show volume control on iOS

parent abae27e3
...@@ -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', 'VideoVolumeControl', 'VideoProgressSlider']
unless $.inArray(part, enableParts) >= 0 unless $.inArray(part, enableParts) >= 0
spyOn window, part spyOn window, part
...@@ -49,6 +49,7 @@ jasmine.stubVideoPlayer = (context, enableParts) -> ...@@ -49,6 +49,7 @@ 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()
if createPlayer
return new VideoPlayer context.video return new VideoPlayer context.video
spyOn(window, 'onunload') spyOn(window, 'onunload')
......
describe 'VideoPlayer', -> describe 'VideoPlayer', ->
beforeEach -> beforeEach ->
jasmine.stubVideoPlayer @ jasmine.stubVideoPlayer @, [], false
afterEach -> afterEach ->
YT.Player = undefined YT.Player = undefined
...@@ -11,7 +11,10 @@ describe 'VideoPlayer', -> ...@@ -11,7 +11,10 @@ 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" />')
describe 'always', ->
beforeEach ->
@player = new VideoPlayer @video @player = new VideoPlayer @video
it 'instanticate current time to zero', -> it 'instanticate current time to zero', ->
...@@ -67,13 +70,35 @@ describe 'VideoPlayer', -> ...@@ -67,13 +70,35 @@ describe 'VideoPlayer', ->
expect($(document)).toHandleWith 'keyup', @player.bindExitFullScreen expect($(document)).toHandleWith 'keyup', @player.bindExitFullScreen
it 'bind to fullscreen switching button', -> it 'bind to fullscreen switching button', ->
console.debug $('.add-fullscreen')
expect($('.add-fullscreen')).toHandleWith 'click', @player.toggleFullScreen 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()
......
...@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment