40 lines
904 B
CoffeeScript
40 lines
904 B
CoffeeScript
$ = jQuery
|
|
context = window
|
|
logger = context.JK.logger
|
|
rest = context.JK.Rest()
|
|
EVENTS = context.JK.EVENTS
|
|
|
|
|
|
JamTrackPreviewActions = @JamTrackPreviewActions
|
|
|
|
@JamTrackPreviewStore = Reflux.createStore(
|
|
{
|
|
listenables: JamTrackPreviewActions
|
|
logger: context.JK.logger
|
|
nowPlaying: []
|
|
|
|
init: ->
|
|
# Register with the app store to get @app
|
|
this.listenTo(context.AppStore, this.onAppInit)
|
|
|
|
onAppInit: (app) ->
|
|
@app = app
|
|
|
|
onStartedPlaying: (preview) ->
|
|
|
|
for playingSound in @nowPlaying
|
|
playingSound.issueStop()
|
|
@nowPlaying = []
|
|
@nowPlaying.push(preview)
|
|
|
|
onStoppedPlaying: (preview) ->
|
|
@nowPlaying.splice(preview)
|
|
if @nowPlaying.length > 0
|
|
@logger.warn("multiple jamtrack previews playing")
|
|
|
|
onScreenChange: () ->
|
|
for playingSound in @nowPlaying
|
|
playingSound.issueStop()
|
|
@nowPlaying = []
|
|
}
|
|
) |