lib/playa/controllers/controller.rb in playa-0.0.15 vs lib/playa/controllers/controller.rb in playa-0.1.0
- old
+ new
@@ -7,75 +7,39 @@
trigger(:_menu_select_, 'playlist')
trigger(:select, trigger(:_menu_selected_, 'playlist'))
trigger(:update)
end
- event :_initialize_ do
- trigger(:show_startup)
- end
+ event(:_initialize_) { trigger(:show_startup) }
+ event(:select) { |track| trigger(:play, track) }
+ event(:show_startup) { StartupView.new.show }
+ event(:show_help) { HelpView.new.show }
- event :key do |key|
- case key
- when :left, 'h' then trigger(:rewind)
- when :right, 'l' then trigger(:forward)
- when ' ' then trigger(:toggle)
- when :up, 'k' then
- trigger(:_menu_prev_, 'playlist')
- trigger(:update)
-
- when :down, 'j' then
- trigger(:_menu_next_, 'playlist')
- trigger(:update)
-
- when '?' then trigger(:show_help)
- when 'p', 's' then trigger(:show_player)
- when 'q' then trigger(:_exit_)
- when :enter then
- trigger(:_menu_select_, 'playlist')
- trigger(:select, trigger(:_menu_selected_, 'playlist'))
- trigger(:update)
-
- end
- end
-
- event :select do |track|
- trigger(:play, track)
- end
-
event :update do
- PlaylistView.render
+ PlaylistView.new.show
+
trigger(:_refresh_playlist_)
end
def initialize(args = [])
@args = args
-
@player = Player.new
@player.events.on(:position_change) { trigger(:progress_update) }
@player.events.on(:complete) { trigger(:complete) }
- event :show_startup do
+ event :show_player do
trigger(:_clear_)
- StartupView.render
- trigger(:_refresh_group_player_)
- end
- event :show_help do
- trigger(:_clear_)
- HelpView.render
- trigger(:_refresh_help_)
- end
+ PlaylistView.new.show
+ StatusView.new.show
+ ProgressView.new(@player).show
- event :show_player do
- trigger(:_clear_)
- PlaylistView.render
- StatusView.render
- ProgressView.render(@player)
trigger(:_refresh_group_player_)
end
event(:progress_update, { delay: 0.5 }) do
- ProgressView.render(@player)
+ ProgressView.new(@player).show
+
trigger(:_refresh_progress_)
end
menu('playlist') { items(tracks) }
end