Skip to content

Commit

Permalink
Slight refactoring, Plugin fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoch committed Sep 30, 2014
1 parent 74ad2fa commit 9e589d3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
3 changes: 3 additions & 0 deletions lib/plugin_handler.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ class PluginHandler
console.log "Loading Plugins..."
root_dir = require('path').dirname require.main.filename
require("fs").readdirSync("#{root_dir}/plugins").forEach (file) =>
# We only want javascript or coffee files
return if file.substr(-3) != '.js' && file.substr(-7) != '.coffee'

plugin = require("#{root_dir}/plugins/" + file)()
@plugins.push plugin
console.log " -- #{plugin.name}"
Expand Down
15 changes: 9 additions & 6 deletions lib/spotify_handler.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SpotifyHandler
ready: @spotify_connected.bind(@)
logout: @spotify_disconnected.bind(@)
@spotify.player.on
endOfTrack: @skip.bind(this)
endOfTrack: @skip.bind(@)

# And off we got
@connect()
Expand Down Expand Up @@ -72,6 +72,9 @@ class SpotifyHandler
# Simply replaces the current playlist-instance with the new one and re-bind events.
# Player-internal state (number of tracks in the playlist, current index, etc.) is updated on @get_next_track().
update_playlist: (err, playlist, tracks, position) ->
if @state.playlist.object?
# Remove event handlers from the old playlist
@state.playlist.object.off()
@state.playlist.object = playlist
@state.playlist.object.on
tracksAdded: @update_playlist.bind(this)
Expand Down Expand Up @@ -180,12 +183,12 @@ class SpotifyHandler
# The actual handling of the new playlist once it has been loaded.
_set_playlist_callback: (name, playlist) ->
@state.playlist.name = name
@state.playlist.object = playlist
@state.playlist.object.on
tracksAdded: @update_playlist.bind(this)
tracksRemoved: @update_playlist.bind(this)

# Update our internal state
@update_playlist null, playlist

@state.track.index = 0
@play @state.playlist.object.getTrack @state.track.index
@play @state.playlist.object.getTrack(@state.track.index)
# Also store the name as our last_playlist for the next time we start up
@storage.setItem 'last_playlist', name
return
Expand Down
1 change: 0 additions & 1 deletion lib/volume_handler.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class VolumeHandler
vol = @step_to_volume step
@exec('amixer sset PCM,0 ' + vol + '%', (error, stdout, stderr) -> )
@current_step = step
# console.info "Set current volume to #{vol}% / Step #{@current_step}"

up: () ->
@set @current_step+1
Expand Down

0 comments on commit 9e589d3

Please sign in to comment.