context = window logger = context.JK.logger rest = context.JK.Rest() mixins = [] # make sure this is actually us opening the window, not someone else (by checking for MixerStore) # this check ensures we attempt to listen if this component is created in a popup reactContext = if window.opener? then window.opener else window accessOpener = false if window.opener? try m = window.opener.MixerStore accessOpener = true catch e reactContext = window VideoLiveStreamStore = reactContext.VideoLiveStreamStore VideoLiveStreamActions = reactContext.VideoLiveStreamActions AppActions = reactContext.AppActions if accessOpener mixins.push(Reflux.listenTo(VideoLiveStreamStore,"onVideoLiveStreamChanged")) @PopupVideoLiveStream = React.createClass({ mixins: mixins onVideoLiveStreamChanged: (videoLiveStream) -> if @unloaded return logger.debug("onVideoLiveStreamChanged", videoLiveStream) this.setState({videoLiveStream: videoLiveStream}) render: () -> # there are a few initial states: if auth is null, we don't know yet (and are checking against the server) # if auth is set, then we can show the upload btn # and if auth == false, then we need the user to try and log in if @state.auth == false action = `` instructions = `
To upload this recording to YouTube, you must give JamKazam the necessary access to your YouTube account by clicking the button below.
` else if @state.videoLiveStream videoLiveStream = @state.videoLiveStream if videoLiveStream.broadcast? logger.debug("broadcast_data", videoLiveStream.broadcast) try data = JSON.parse(videoLiveStream.broadcast.broadcast_data) controlsUrl = "https://www.youtube.com/live_event_analytics?v=" + data.id videoUrl = "https://www.youtube.com/watch?v=" + data.id controlLink = `Open Broadcast Controls` videoLink = `Open Video Page` catch e logger.error("unable to parse broadcast data", e) if videoLiveStream.errorMessage action = null instructions = `The stream setup failed. Reason: ({videoLiveStream.errorMessage})
` else if @state.auth == false action = `` instructions = `To upload this recording to YouTube, you must give JamKazam the necessary access to your YouTube account by clicking the button below.
` else if videoLiveStream.streaming action = `` instructions = `{videoLink}{controlLink}
` else if videoLiveStream.creatingBroadcast action = null instructions = `Synchronizing with YouTube
` else if videoLiveStream.waitingOnReady action = null instructions = `Synchronizing with YouTube ... waiting on stream setup
` else if videoLiveStream.waitingOnTesting || videoLiveStream.transitioningTesting action = null instructions = `Synchronizing with YouTube ... stream is ready ... preparing ...
` else if videoLiveStream.waitingOnLive action = null instructions = `Synchronizing with YouTube ... stream is ready ... waiting to go live ...
` else if !@state.initiated action = `START BROADCASTING` if videoLiveStream.broadcast instructions = `Click 'Start Broadcasting' to setup a live streaming session on YouTube.
` else instructions = `Press 'Start Broadcasting' to start broadcasting on YouTube.
` else if @state.initiated instructions = `Streaming initiated. Please wait...
` else name = null action = null instructions = `UNKNOWN STATE: {JSON.stringify(videoLiveStream)}
` else name = 'Loading...' action = null `