Skip to content

Commit

Permalink
Cleanup befor epushing for Akash
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrove committed Apr 13, 2012
1 parent 5545290 commit be19af7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
3 changes: 1 addition & 2 deletions app/assets/javascripts/backbone/kandan.js.coffee.erb
Expand Up @@ -68,8 +68,7 @@ window.Kandan =
$('#kandan').tabs({
select: (event, ui)->
$(document).data('active-channel-id',
Kandan.Helpers.Channels.getChannelIdByTabIndex(ui.index)
Kandan.Plugins.MusicPlayer.notifyChannelChanged())
Kandan.Helpers.Channels.getChannelIdByTabIndex(ui.index))
Kandan.Data.Channels.runCallbacks('change')
add: (event, ui) ->
$('.header .ui-tabs-panel:last').detach().appendTo('#channels')
Expand Down
29 changes: 18 additions & 11 deletions app/assets/javascripts/backbone/plugins/music_player.js.coffee
Expand Up @@ -44,6 +44,7 @@ class Kandan.Plugins.MusicPlayer
# TODO: Add support for sounds
@init: (pluginId)->
@pluginId = pluginId
Kandan.Data.Channels.registerCallback(@onChannelChange)
@registerModifier()
@registerWidget()

Expand All @@ -59,7 +60,7 @@ class Kandan.Plugins.MusicPlayer
if true and Kandan.Helpers.Channels.getActiveChannelId()? # state == Kandan.Helpers.Activities.ACTIVE_STATE
console.log("message: " + message.content)
console.log("url: " + url)
@playUrl(Kandan.Helpers.Channels.getActiveChannelId(), Kandan.Helpers.Utils.unescape(url))
@playUrl(message.channel_id, Kandan.Helpers.Utils.unescape(url))
else
console.log "song is history"

Expand Down Expand Up @@ -130,15 +131,21 @@ class Kandan.Plugins.MusicPlayer
@setAudioUrl(channelId, url)
@audioChannel(channelId).play()

@notifyChannelChanged: () ->
# Guards are
for channel in @audioChannels()
console.log("muting all channels!")
console.log(channel)
@mute(channel) if channel?
channelId = Kandan.Helpers.Channels.getActiveChannelId()
if @audioChannel(channelId)?
console.log("unmuting channel #{channelId}")
@unmute(channelId)
@currentChannel: () ->
$(document).data("activeChannelId")

@onChannelChange: () ->
channelId = @currentChannel()
console.log("Current channel: #{channelId}")
if channelId
for channel in @audioChannels()
console.log("muting all channels!")
console.log(channel)
id = channel.id.split("_")[1]
@mute(id) if id? and id != channelId

if @audioChannel(channelId)?
console.log("unmuting channel #{channelId}")
@unmute(channelId)

# Kandan.Plugins.register "Kandan.Plugins.MusicPlayer"

0 comments on commit be19af7

Please sign in to comment.