Class: Qtunes::Player
- Inherits:
-
Object
- Object
- Qtunes::Player
- Defined in:
- lib/qtunes/player.rb
Constant Summary collapse
- INFO_KEYS =
%w(status file duration position)
Instance Method Summary collapse
- #enqueue(file) ⇒ Object
- #execute(command) ⇒ Object
- #file ⇒ Object
- #info ⇒ Object
- #info_raw ⇒ Object
- #library ⇒ Object
- #next ⇒ Object
- #pause ⇒ Object
- #paused? ⇒ Boolean
- #play ⇒ Object
- #playing? ⇒ Boolean
- #prev ⇒ Object
- #queue ⇒ Object
-
#status ⇒ Object
The current state of the player.
- #stop ⇒ Object
- #stopped? ⇒ Boolean
- #view_queue ⇒ Object
- #win_down ⇒ Object
- #win_remove ⇒ Object
- #win_top ⇒ Object
Instance Method Details
#enqueue(file) ⇒ Object
85 86 87 |
# File 'lib/qtunes/player.rb', line 85 def enqueue(file) Cocaine::CommandLine.new('cmus-remote', "-q #{file.shellescape}").run end |
#execute(command) ⇒ Object
97 98 99 |
# File 'lib/qtunes/player.rb', line 97 def execute(command) Cocaine::CommandLine.new('cmus-remote', '-C :command', :command => command).run end |
#file ⇒ Object
45 46 47 |
# File 'lib/qtunes/player.rb', line 45 def file info['file'] end |
#info ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/qtunes/player.rb', line 12 def info info_raw.inject({}) do |res,i| k,v = i.split(" ", 2) res[k] = v if INFO_KEYS.include?(k) res end end |
#info_raw ⇒ Object
8 9 10 |
# File 'lib/qtunes/player.rb', line 8 def info_raw execute("status").split("\n") end |
#library ⇒ Object
93 94 95 |
# File 'lib/qtunes/player.rb', line 93 def library execute('save -l -').split("\n") end |
#next ⇒ Object
77 78 79 |
# File 'lib/qtunes/player.rb', line 77 def next execute('player-next') end |
#pause ⇒ Object
73 74 75 |
# File 'lib/qtunes/player.rb', line 73 def pause execute('player-pause') end |
#paused? ⇒ Boolean
41 42 43 |
# File 'lib/qtunes/player.rb', line 41 def paused? status == 'paused' end |
#play ⇒ Object
65 66 67 |
# File 'lib/qtunes/player.rb', line 65 def play execute('player-play') end |
#playing? ⇒ Boolean
33 34 35 |
# File 'lib/qtunes/player.rb', line 33 def status == 'playing' end |
#prev ⇒ Object
81 82 83 |
# File 'lib/qtunes/player.rb', line 81 def prev execute('player-prev') end |
#queue ⇒ Object
89 90 91 |
# File 'lib/qtunes/player.rb', line 89 def queue execute('save -q -').split("\n") end |
#status ⇒ Object
29 30 31 |
# File 'lib/qtunes/player.rb', line 29 def status info['status'] end |
#stop ⇒ Object
69 70 71 |
# File 'lib/qtunes/player.rb', line 69 def stop execute('player-stop') end |
#stopped? ⇒ Boolean
37 38 39 |
# File 'lib/qtunes/player.rb', line 37 def stopped? status == 'stopped' end |
#view_queue ⇒ Object
49 50 51 |
# File 'lib/qtunes/player.rb', line 49 def view_queue execute('view queue') end |
#win_down ⇒ Object
57 58 59 |
# File 'lib/qtunes/player.rb', line 57 def win_down execute('win-down') end |
#win_remove ⇒ Object
61 62 63 |
# File 'lib/qtunes/player.rb', line 61 def win_remove execute('win-remove') end |
#win_top ⇒ Object
53 54 55 |
# File 'lib/qtunes/player.rb', line 53 def win_top execute('win-top') end |