context = window PLAYBACK_MONITOR_MODE = context.JK.PLAYBACK_MONITOR_MODE EVENTS = context.JK.EVENTS logger = context.JK.logger mixins = [] # this check ensures we attempt to listen if this component is created in a popup reactContext = if window.opener? then window.opener else window # make sure this is actually us opening the window, not someone else (by checking for MixerStore) if window.opener? try m = window.opener.MixerStore catch e reactContext = window # temporarily.. # reactContext = window if true # if /iPhone|iPad|iPod/i.test(navigator.userAgent) # iPad or iPhone reactContext = window MediaPlaybackActions = reactContext.MediaPlaybackActions BrowserMediaStore = reactContext.BrowserMediaStore BrowserMediaPlaybackStore = reactContext.BrowserMediaPlaybackStore BrowserMediaPlaybackActions = reactContext.BrowserMediaPlaybackActions mixins.push(Reflux.listenTo(BrowserMediaPlaybackStore,"onMediaStateChanged")) @BrowserMediaControls = React.createClass({ mixins: mixins tempos : [ 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 63, 66, 69, 72, 76, 80, 84, 88, 92, 96, 100, 104, 108, 112, 116, 120, 126, 132, 138, 144, 152, 160, 168, 176, 184, 192, 200, 208 ] onMediaStateChanged: (changes) -> if changes.playbackStateChanged if @state.controls? if changes.playbackState == 'play_start' @state.controls.onPlayStartEvent() else if changes.playbackState == 'play_stop' @state.controls.onPlayStopEvent() else if changes.playbackState == 'play_pause' @state.controls.onPlayPauseEvent(); if changes.positionUpdateChanged if @state.controls? @state.controls.executeMonitor(changes.positionMs, changes.durationMs, changes.isPlaying) if changes.currentTimeChanged @setState({time: changes.time}) monitorControls: (controls) -> controls.startMonitor(PLAYBACK_MONITOR_MODE.BROWSER_MEDIA) render: () -> tempo_options = [] for tempo in @tempos tempo_options.push(``) `
` getInitialState: () -> {controls: null, time: '0:00'} componentDidUpdate: (prevProps, prevState) -> componentDidMount: () -> $root = jQuery(this.getDOMNode()) controls = context.JK.PlaybackControls($root, {mediaActions: BrowserMediaPlaybackActions}) controls.setDisabled(@props.disabled) @monitorControls(controls) @setState({controls:controls}) componentWillUpdate: (nextProps) -> @state.controls.setDisabled(nextProps.disabled) if @state.controls? })