context = window mixins = [] ExternalVideoStore = context.ExternalVideoStore mixins.push(Reflux.listenTo(ExternalVideoStore, "onExternalVideoStateChanged")) mixins.push(Reflux.listenTo(RecordingStore, "onRecordingStateChanged")) @SessionRecordingSettings = React.createClass({ mixins: mixins onExternalVideoStateChanged: (videoState) -> console.log('_REC_ onExternalVideoStateChanged', videoState); $root = $(this.getDOMNode()) if videoState.videoEnabled $root.find('#recording-input-both').attr('disabled', false).iCheck('update').iCheck('uncheck') else $root.find('#recording-input-both').prop('disabled',true).iCheck('update').iCheck('uncheck'); $root.find('#recording-input-audio').attr('checked', true).iCheck('update').iCheck('check') # onRecordingStateChanged: (recordingState) -> # if recordingState.audioRecordingFormat # @setState({audioFormat: recordingState.audioRecordingFormat}) onRecordingStateChanged: `function (recordingState) { console.log('_REC_ onRecordingStateChanged', recordingState); if (recordingState.audioRecordingFormat) { this.setState({audioFormat: recordingState.audioRecordingFormat}); } // This checks to see if we can clear out the grayed out state on the submit button if(this.state.startRequested && (recordingState.cause == 'started' || (recordingState.reason == 'rest' && recordingState.isRecording == false))) { this.setState({startRequested: false}) } }` getInitialState: () -> try settings = localStorage.getItem('recordSettings') rs = JSON.parse(settings) { recordingType: rs.recordingType, audioFormat: rs.audioFormat, audioStoreType: rs.audioStoreType, videoFormat: rs.videoFormat, audioDelay: rs.audioDelay, includeChat: rs.includeChat, startRequested: false, } catch e console.error('error loading recording settings from local storage', e.message) logger.log(e.stack) { recordingType: context.JK.RECORD_TYPE_AUDIO, recordingName: '', audioFormat: 'mp3', audioStoreType: context.JK.AUDIO_STORE_TYPE_MIX_AND_STEMS['key'], videoFormat: 'mp4', audioDelay: 100, includeChat: false, startRequested: false } setRecordingNameChange: (e) -> @setState(recordingName: e.target.value) # setRecordingTypeChange: (e) -> # recordType = e.target.value # $root = $(@getDOMNode()) # $recordTypeAudio = $root.find('#recording-input-audio') # $recordTypeBoth = $root.find('#recording-input-both') # if recordType == context.JK.RECORD_TYPE_BOTH # if not $recordTypeBoth.attr('disabled') # $recordTypeBoth.iCheck('check').attr('checked', true) # @toggleDisableVideoContrls(false) # else # $recordTypeAudio.iCheck('check').attr('checked', true) # @toggleDisableVideoContrls(true) # obsReady = true #hardcoded for now # if !$recordTypeBoth.prop('disabled') && recordType == context.JK.RECORD_TYPE_BOTH && !obsReady # context.JK.Banner.showAlert("To make a video recording in JamKazam, you must first install and configure OBS software. Click the link below for a help article that explains how to do this. View Help Article") # setTimeout (-> # $recordTypeAudio.prop('checked', true).iCheck('update').iCheck('check') # $recordTypeBoth.prop('checked', false).iCheck('update').iCheck('uncheck') # ), 1000 # return # @setState(recordingType: recordType) setRecordingTypeChange: `async function(e) { const recordType = e.target.value; const $root = $(this.getDOMNode()); const $recordTypeAudio = $root.find('#recording-input-audio'); const $recordTypeBoth = $root.find('#recording-input-both'); if (recordType === context.JK.RECORD_TYPE_BOTH) { if (!$recordTypeBoth.attr('disabled')) { $recordTypeBoth.iCheck('check').attr('checked', true); this.toggleDisableVideoContrls(false); } } else { $recordTypeAudio.iCheck('check').attr('checked', true); this.toggleDisableVideoContrls(true); } const obsAvailable = await context.jamClient.IsOBSAvailable(); if (!$recordTypeBoth.prop('disabled') && (recordType === context.JK.RECORD_TYPE_BOTH) && !obsAvailable) { context.JK.Banner.showAlert(context.JK.ALERT_MESSAGES.OBS_UNAVAILABLE); setTimeout((function() { $recordTypeAudio.prop('checked', true).iCheck('update').iCheck('check'); $recordTypeBoth.prop('checked', false).iCheck('update').iCheck('uncheck'); }), 1000); return; } this.setState({recordingType: recordType}); }` setAudioFormatChange: (e) -> $root = $(@getDOMNode()) audioFormat = $root.find("#audio-format").val() @setState(audioFormat: audioFormat) setVideoFormatChange: (e) -> $root = $(@getDOMNode()) videoFormat = $root.find("#video-format").val() @setState(videoFormat: videoFormat) setAudioStoreTypeChange: (e) -> $root = $(@getDOMNode()) audioStoreType = e.target.value; $audioStoreTypeMixAndStems = $root.find('#audio-store-type-mix-and-stems') $audioStoreTypeMix = $root.find('#audio-store-type-mix') if audioStoreType == context.JK.AUDIO_STORE_TYPE_MIX_AND_STEMS['key'] $audioStoreTypeMixAndStems.iCheck('check').attr('checked', true) $audioStoreTypeMix.iCheck('uncheck').attr('checked', false) context.jamClient.SetAudioRecordingPreference(context.JK.AUDIO_STORE_TYPE_MIX_AND_STEMS['backendValues'][0]) else $audioStoreTypeMixAndStems.iCheck('uncheck').attr('checked', false) $audioStoreTypeMix.iCheck('check').attr('checked', true) context.jamClient.SetAudioRecordingPreference(context.JK.AUDIO_STORE_TYPE_MIX_ONLY['backendValues'][0]) @setState(audioStoreType: audioStoreType) toggleDisableVideoContrls: (isDisable) -> $root = $(@getDOMNode()) $videoFormat = $root.find("#video-format") $audioDelay = $root.find("#audio-delay") $videoFormat.attr('disabled', isDisable) $audioDelay.attr('disabled', isDisable) setAudioDelay: (e) -> @setState(audioDelay: e.target.value) setIncludeChat: (e) -> @setState(includeChat: e.target.checked) cancel: (e) -> e.preventDefault() @props.handleCancel() startRecording: (e) -> e.preventDefault() if @state.startRequested == true console.log("recording already attempted; ignoring") return; if @isFormValid() @setState(startRequested: true) @props.handleSubmit(@state) else context.JK.Banner.showAlert("Name can not be blank.") isFormValid: (e) -> $root = $(@getDOMNode()) $recName = $root.find('#recording-name') $recName.val().trim().length > 0 render: () -> audioFormatOptions = [] videoFormatOptions = [] for format, i in context.JK.AUDIO_FORMATS if format == @state.audioFormat audioFormatOptions.push `` else audioFormatOptions.push `` for format, i in context.JK.VIDEO_FORMATS videoFormatOptions.push `` startRecordingClasses = classNames({"button-orange": true, disabled: this.state.startRequested}) `
` # componentDidMount: () -> # $root = jQuery(this.getDOMNode()) # context.JK.dropdown($root.find('select')) # $inputAudioRadioBtn = $root.find('#recording-input-audio') # $inputBothRadioBtn = $root.find('#recording-input-both') # $inputBothRadioBtn.on('ifClicked', this.setRecordingTypeChange) # $inputAudioRadioBtn.on('ifClicked', this.setRecordingTypeChange) # $inputRecordStoreTypeMixAndStems = $root.find('#audio-store-type-mix-and-stems') # $inputRecordStoreTypeMix = $root.find('#audio-store-type-mix') # $inputRecordStoreTypeMixAndStems.on('ifClicked', this.setAudioStoreTypeChange) # $inputRecordStoreTypeMix.on('ifClicked', this.setAudioStoreTypeChange) # context.JK.checkbox($inputRecordStoreTypeMixAndStems) # context.JK.checkbox($inputRecordStoreTypeMix) # #only enable audio & video radio button if a video is ongoing # if !context.JK.videoIsOngoing # @setState({recordingType: context.JK.RECORD_TYPE_AUDIO}) # $inputAudioRadioBtn.attr('checked', true).iCheck('update').iCheck('check') # $inputBothRadioBtn.attr('disabled',true).iCheck('update').iCheck('uncheck') # @toggleDisableVideoContrls(true) # else # $inputBothRadioBtn.attr('disabled', false).iCheck('update') # if @state.recordingType == context.JK.RECORD_TYPE_BOTH # $inputBothRadioBtn.attr('checked', true).iCheck('update').iCheck('check') # @toggleDisableVideoContrls(false) # context.JK.checkbox($inputAudioRadioBtn) # context.JK.checkbox($inputBothRadioBtn) # $includeChatCheckbox = $root.find('#include-chat') # $includeChatCheckbox.iCheck('check').attr('checked', @state.includeChat) # $includeChatCheckbox.on 'ifToggled', (e) => # @setState(includeChat: e.target.checked) # context.JK.checkbox($includeChatCheckbox) # context.JK.helpBubble($root.find(".audio-store-type-mix-and-stems-help"), "audio-store-type-mix-and-stems", {}, {offsetParent:$root.closest('.top-parent'), positions: ['right', 'bottom'], width:450}) # context.JK.helpBubble($root.find(".include-chat-help"), "include-chat-in-recording", {}, {offsetParent:$root.closest('.top-parent'), positions: ['right', 'bottom'], width:450}) # context.JK.helpBubble($root.find(".audio-delay-help"), "audio-delay-in-recording", {}, {offsetParent:$root.closest('.top-parent'), positions: ['right', 'bottom'], width:450}) updateAudioStoreState: `function (audioStoreType) { const $root = $(this.getDOMNode()); const $audioStoreTypeMixAndStems = $root.find('#audio-store-type-mix-and-stems'); const $audioStoreTypeMix = $root.find('#audio-store-type-mix'); if (context.JK.AUDIO_STORE_TYPE_MIX_AND_STEMS['backendValues'].indexOf(audioStoreType) > -1) { $audioStoreTypeMixAndStems.iCheck('check').attr('checked', true); $audioStoreTypeMix.iCheck('uncheck').attr('checked', false); } else { $audioStoreTypeMixAndStems.iCheck('uncheck').attr('checked', false); $audioStoreTypeMix.iCheck('check').attr('checked', true); } }` componentDidMount: `function(){ const $root = jQuery(this.getDOMNode()); context.JK.dropdown($root.find('select')); const $inputAudioRadioBtn = $root.find('#recording-input-audio'); const $inputBothRadioBtn = $root.find('#recording-input-both'); $inputBothRadioBtn.on('ifClicked', this.setRecordingTypeChange); $inputAudioRadioBtn.on('ifClicked', this.setRecordingTypeChange); const $inputRecordStoreTypeMixAndStems = $root.find('#audio-store-type-mix-and-stems'); const $inputRecordStoreTypeMix = $root.find('#audio-store-type-mix'); //get the audio store type from backend and set the radio button accordingly using jamClient.GetAudioRecordingPreference() context.jamClient.GetAudioRecordingPreference().then((audioStoreType) => { this.updateAudioStoreState(audioStoreType); }); $inputRecordStoreTypeMixAndStems.on('ifClicked', this.setAudioStoreTypeChange); $inputRecordStoreTypeMix.on('ifClicked', this.setAudioStoreTypeChange); context.JK.checkbox($inputRecordStoreTypeMixAndStems); context.JK.checkbox($inputRecordStoreTypeMix); //only enable audio & video radio button if a video is ongoing if (!context.JK.videoIsOngoing) { this.setState({recordingType: context.JK.RECORD_TYPE_AUDIO}); $inputAudioRadioBtn.attr('checked', true).iCheck('update').iCheck('check'); $inputBothRadioBtn.attr('disabled',true).iCheck('update').iCheck('uncheck'); this.toggleDisableVideoContrls(true); } else { $inputBothRadioBtn.attr('disabled', false).iCheck('update'); if (this.state.recordingType === context.JK.RECORD_TYPE_BOTH) { $inputBothRadioBtn.attr('checked', true).iCheck('update').iCheck('check'); this.toggleDisableVideoContrls(false); } } context.JK.checkbox($inputAudioRadioBtn); context.JK.checkbox($inputBothRadioBtn); const $includeChatCheckbox = $root.find('#include-chat'); $includeChatCheckbox.iCheck('check').attr('checked', this.state.includeChat); $includeChatCheckbox.on('ifToggled', e => { return this.setState({includeChat: e.target.checked}); }); context.JK.checkbox($includeChatCheckbox); context.JK.helpBubble($root.find(".audio-store-type-mix-and-stems-help"), "audio-store-type-mix-and-stems", {}, {offsetParent:$root.closest('.top-parent'), positions: ['right', 'bottom'], width:450}); context.JK.helpBubble($root.find(".include-chat-help"), "include-chat-in-recording", {}, {offsetParent:$root.closest('.top-parent'), positions: ['right', 'bottom'], width:450}); return context.JK.helpBubble($root.find(".audio-delay-help"), "audio-delay-in-recording", {}, {offsetParent:$root.closest('.top-parent'), positions: ['right', 'bottom'], width:450}); }` # componentDidUpdate: () -> # console.log('componentDidUpdate') # $root = $(this.getDOMNode()) # context.JK.dropdown($root.find('select')) # $root.find('#audio-format').unbind('change').change(this.setAudioFormatChange) # $root.find('#video-format').unbind('change').change(this.setVideoFormatChange) # #$root.find('#audio-store-types').unbind('change').change(this.setAudioStoreTypeChange) componentDidUpdate: `function () { context.jamClient.GetAudioRecordingPreference().then((audioStoreType) => { //console.log('_REC_ componentDidUpdate audioStoreType', audioStoreType); this.updateAudioStoreState(audioStoreType); }); const $root = $(this.getDOMNode()); context.JK.dropdown($root.find('select')); $root.find('#audio-format').unbind('change').change(this.setAudioFormatChange); $root.find('#video-format').unbind('change').change(this.setVideoFormatChange); }` })