12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/soundcloud9000/controllers/track_controller.rb', line 12
def initialize(view, client)
super(view)
@client = client
events.on(:key) do |key|
case key
when :enter
@view.select
events.trigger(:select, current_track)
when :up, :k
@view.up
when :down, :j
@view.down
@tracks.load_more if @view.bottom?
when :u
user = fetch_user_with_message('Change to soundcloud user: ')
unless user.nil?
@client.current_user = user
@tracks.collection_to_load = :user
@tracks.clear_and_replace
end
when :f
@client.current_user = fetch_user_with_message('Change to SoundCloud user\'s favourites: ') if @client.current_user.nil?
unless @client.current_user.nil?
@tracks.collection_to_load = :favorites
@tracks.clear_and_replace
end
when :s
@view.clear
@client.current_user = fetch_user_with_message('Change to SoundCloud user: ') if @client.current_user.nil?
unless @client.current_user.nil?
set = UI::Input.getstr('Change to SoundCloud playlist: ')
set_request = @client.resolve(@client.current_user.permalink + '/sets/' + set)
if set_request.nil?
UI::Input.error("No such set/playlist '#{set}' for #{@client.current_user.username}")
@client.current_user = nil
else
@tracks.playlist = Models::Playlist.new(set_request)
@tracks.collection_to_load = :playlist
@tracks.clear_and_replace
end
end
when :m
@tracks.shuffle = !@tracks.shuffle
UI::Input.message("Shuffle #{@tracks.shuffle ? 'enabled' : 'disabled'}.")
when :h
@tracks.help = !@tracks.help
if @tracks.help
height = 40
width = 80
top = (Curses.lines - height) / 2
left = (Curses.cols - width) / 2
win = Curses::Window.new(height, width, top, left)
win.attrset(Curses.color_pair(4) | Curses::A_REVERSE | Curses::A_BOLD)
win.setpos(2, 3)
help = Application.get_help
win.addstr(help)
win.setpos(help.lines.count, 0)
win.addstr('-' * width)
win.setpos(help.lines.count + 1, 3)
shortcuts = %(
Shortcuts:
[enter]/[ctrl-J] play selected track from beginning
[down]/j select track below currently selected track
[up]/k select track above currently selected track
[space] play or pause the current track
[right]/[left] move backward or forward in current track
1 jump to the time at 1/10 of the current track
2 jump to the time at 2/10 of the current track
3 jump to the time at 3/10 of the current track
4 jump to the time at 4/10 of the current track
5 jump to the time at 5/10 of the current track
6 jump to the time at 6/10 of the current track
7 jump to the time at 7/10 of the current track
8 jump to the time at 8/10 of the current track
9 jump to the time at 9/10 of the current track
u play tracks of different users
f play favorites from a user
s play sets/playlists from a user
m play songs in random order
h toggle this help screen
o change order of tracks
)
win.addstr(shortcuts)
win.box('|', '-')
win.refresh
win.getch
win.close
else
@tracks.clear_and_replace
end
when :o
p 'order'
end
end
end
|