Module: Muzak::Player

Extended by:
Utils
Defined in:
lib/muzak/player.rb,
lib/muzak/player/mpv.rb,
lib/muzak/player/stub_player.rb

Overview

The namespace for muzak players.

Defined Under Namespace

Classes: MPV, StubPlayer

Constant Summary collapse

PLAYER_MAP =

An association of shorthand player "names" to Class objects.

{
  "stub" => Player::StubPlayer,
  "mpv" => Player::MPV
}.freeze

Class Method Summary collapse

Methods included from Utils

album_art?, build_response, danger, debug, debug?, error, error!, music?, output, pretty, verbose, verbose?, which?

Class Method Details

.load_player!(instance) ⇒ StubPlayer

Returns an instantiated player as specified in Config.player.

Returns:



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/muzak/player.rb', line 19

def self.load_player!(instance)
  klass = PLAYER_MAP[Config.player]

  error! "#{Config.player} isn't a known player" unless klass

  if klass.available?
    klass.new(instance)
  else
    error! "#{Config.player} isn't available, do you need to install it?"
  end
end