Class: XiamiRadio::View::Player

Inherits:
Object
  • Object
show all
Includes:
Curses
Defined in:
lib/xiami_radio/view/player.rb

Instance Method Summary collapse

Constructor Details

#initializePlayer

Returns a new instance of Player.



8
9
10
11
12
13
14
15
16
# File 'lib/xiami_radio/view/player.rb', line 8

def initialize
  init_screen
  noecho
  stdscr.keypad true
  curs_set 0
  start_color
  init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK)
  init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK)
end

Instance Method Details

#curses_refreshObject



18
# File 'lib/xiami_radio/view/player.rb', line 18

alias_method :curses_refresh, :refresh

#listen_on(player) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/xiami_radio/view/player.rb', line 27

def listen_on(player)
  Thread.start do
    while (key = getch)
      case key
        when KEY_LEFT
          player.rewind
        when KEY_RIGHT
          player.forward
        when KEY_DOWN
          player.next
        when 'l'
          XiamiRadio::Notice.push player.track.fav
        when ' '
          player.toggle
        else #
      end
    end
  end
end

#refresh(track, position) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/xiami_radio/view/player.rb', line 19

def refresh(track, position)
  render_title_line track
  render_progress_line (position / track.duration), track.downloader.progress
  render_info_line track, position
  render_msg_line
  Curses.refresh
end