152 lines
5.3 KiB
CoffeeScript
152 lines
5.3 KiB
CoffeeScript
$ = jQuery
|
|
context = window
|
|
logger = context.JK.logger
|
|
EVENTS = context.JK.EVENTS
|
|
NAMED_MESSAGES = context.JK.NAMED_MESSAGES
|
|
|
|
VideoActions = @VideoActions
|
|
|
|
@VideoStore = Reflux.createStore(
|
|
{
|
|
listenables: VideoActions
|
|
logger: context.JK.logger
|
|
videoShared: false
|
|
videoOpen : false
|
|
state : null
|
|
|
|
init: ->
|
|
this.listenTo(context.SessionStore, this.onSessionChange)
|
|
|
|
|
|
|
|
# someone has requested us to refresh our config
|
|
onRefresh: ->
|
|
|
|
currentDevice = context.jamClient.FTUECurrentSelectedVideoDevice()
|
|
deviceNames = context.jamClient.FTUEGetVideoCaptureDeviceNames()
|
|
#deviceCaps = context.jamClient.FTUEGetVideoCaptureDeviceCapabilities()
|
|
currentResolution = context.jamClient.GetCurrentVideoResolution()
|
|
currentFrameRate = context.jamClient.GetCurrentVideoFrameRate()
|
|
encodeResolutions = context.jamClient.FTUEGetAvailableEncodeVideoResolutions()
|
|
frameRates = context.jamClient.FTUEGetSendFrameRates()
|
|
|
|
#deviceCaps: deviceCaps,
|
|
|
|
@state = {
|
|
currentDevice: currentDevice,
|
|
deviceNames: deviceNames,
|
|
currentResolution: currentResolution,
|
|
currentFrameRate: currentFrameRate,
|
|
encodeResolutions: encodeResolutions,
|
|
frameRates: frameRates,
|
|
videoShared: @videoShared
|
|
videoOpen: @videoOpen
|
|
}
|
|
this.trigger(@state)
|
|
|
|
onSessionChange: (@session) ->
|
|
|
|
onStartVideo: ->
|
|
if @howtoWindow?
|
|
@howtoWindow.close()
|
|
@howtoWindow = null
|
|
#else # TESTING
|
|
# @howtoWindow = window.open("/popups/how-to-use-video", 'How to Use Video', 'scrollbars=yes,toolbar=no,status=no,height=315,width=320')
|
|
|
|
@logger.debug("SessStartVideoSharing()")
|
|
context.jamClient.SessStartVideoSharing(0)
|
|
@videoShared = true
|
|
|
|
@state.videoShared = @videoShared
|
|
this.trigger(@state)
|
|
|
|
onStopVideo: ->
|
|
if @videoShared
|
|
@logger.debug("SessStopVideoSharing()")
|
|
context.jamClient.SessStopVideoSharing()
|
|
@videoShared = false
|
|
@state.videoShared = @videoShared
|
|
this.trigger(@state)
|
|
|
|
onToggleVideo: () ->
|
|
if @videoShared
|
|
@onStopVideo()
|
|
else
|
|
@onStartVideo()
|
|
|
|
onSetVideoEncodeResolution: (resolution) ->
|
|
context.jamClient.FTUESetVideoEncodeResolution(resolution)
|
|
|
|
onSetSendFrameRate: (frameRates) ->
|
|
context.jamClient.FTUESetSendFrameRates(frameRates)
|
|
|
|
onSelectDevice: (device, caps) ->
|
|
result = context.jamClient.FTUESelectVideoCaptureDevice(device, caps)
|
|
if(!result)
|
|
@logger.error("onSelectDevice failed with device #{device}")
|
|
|
|
onVideoWindowOpened: () ->
|
|
@onRefresh() unless @state?
|
|
|
|
@logger.debug("in session? #{@session.inSession()}, currentDevice? #{@state?.currentDevice?}, videoShared? #{@videoShared}")
|
|
|
|
if @session.inSession() && @state.currentDevice? && Object.keys(@state.currentDevice).length > 0 && !@videoShared
|
|
context.JK.ModUtils.shouldShow(NAMED_MESSAGES.HOWTO_USE_VIDEO_NOSHOW).done((shouldShow) =>
|
|
@logger.debug("checking if user has 'should show' on video howto: #{shouldShow}")
|
|
if shouldShow
|
|
@howtoWindow = window.open("/popups/how-to-use-video", 'How to Use Video', 'scrollbars=yes,toolbar=no,status=no,height=315,width=320')
|
|
)
|
|
|
|
#@howtoWindo.ParentRecordingStore = context.RecordingStore
|
|
#@howtoWindo.ParentIsRecording = @recordingModel.isRecording()
|
|
|
|
@videoOpen = true
|
|
@state.videoOpen = @videoOpen
|
|
this.trigger(@state)
|
|
|
|
onVideoWindowClosed: () ->
|
|
@onRefresh() unless @state?
|
|
|
|
if @howtoWindow?
|
|
@howtoWindow.close()
|
|
@howtoWindow = null
|
|
|
|
@videoOpen = false
|
|
@state.videoOpen = @videoOpen
|
|
@videoShared = false
|
|
@state.videoShared = @videoShared
|
|
this.trigger(@state)
|
|
|
|
onHowToUseVideoPopupClosed: (dontShow) ->
|
|
if (dontShow)
|
|
@logger.debug("requesting that user no longer see how-to-use-video")
|
|
context.JK.ModUtils.updateNoShow(NAMED_MESSAGES.HOWTO_USE_VIDEO_NOSHOW);
|
|
|
|
logger.debug("how-to-use-video popup closed")
|
|
@howtoWindow = null
|
|
|
|
onConfigureVideoPopupClosed: (dontShow) ->
|
|
if (dontShow)
|
|
@logger.debug("requesting that user no longer see configure-video")
|
|
context.JK.ModUtils.updateNoShow(NAMED_MESSAGES.CONFIGURE_VIDEO_NOSHOW);
|
|
|
|
logger.debug("configure-video popup closed")
|
|
@configureWindow = null
|
|
|
|
# if the user passes all the safeguards, let's see if we should get them to configure video
|
|
onCheckPromptConfigureVideo: () ->
|
|
@onRefresh() unless @state?
|
|
|
|
@logger.debug("checkPromptConfigureVideo", @state.currentDevice, @state.deviceNames)
|
|
|
|
# if no device configured and this is the native client and if you have at least 1 video
|
|
if (!@state.currentDevice? || Object.keys(@state.currentDevice).length == 0) && gon?.isNativeClient && Object.keys(@state.deviceNames).length > 0
|
|
# and if they haven't said stop bothering me about this
|
|
context.JK.ModUtils.shouldShow(NAMED_MESSAGES.CONFIGURE_VIDEO_NOSHOW).done((shouldShow) =>
|
|
@logger.debug("checking if user has 'should show' on video config: #{shouldShow}")
|
|
if shouldShow
|
|
@configureWindow = window.open("/popups/configure-video", 'Configure Video', 'scrollbars=yes,toolbar=no,status=no,height=395,width=444')
|
|
)
|
|
}
|
|
)
|