Module: Muzak::Player

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

Overview

The namespace for muzak players.

Defined Under Namespace

Classes: MPD, MPV, MultiPlayer, StubPlayer, VLC

Constant Summary collapse

PLAYER_CLASSES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

All classes (player implementations) under the Muzak::Player namespace.

constants.map(&Player.method(:const_get)).grep(Class).freeze
PLAYER_NAMES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

All human-friendly player names.

PLAYER_CLASSES.map(&:player_name).freeze
PLAYER_MAP =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

An association of human-friendly player names to implementation classes.

PLAYER_NAMES.zip(PLAYER_CLASSES).to_h.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:



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/muzak/player.rb', line 28

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