class Muzak::Player::VLC
Exposes a VLC
process to muzak for playback control.
Public Class Methods
@return [Boolean] whether or not VLC
is available
# File lib/muzak/player/vlc.rb, line 10 def self.available? Utils.which?("vlc") && Utils.which?("cvlc") end
Public Instance Methods
Activates a VLC
process. @return [void]
# File lib/muzak/player/vlc.rb, line 21 def activate! return if running? debug "activating #{self.class}" @vlc = ::VLC::System.new instance.event :player_activated end
Clear VLC's internal queue. @return [void]
# File lib/muzak/player/vlc.rb, line 137 def clear_queue return unless running? @vlc.clear end
Deactivates the VLC
process, if one is running. @return [void]
# File lib/muzak/player/vlc.rb, line 33 def deactivate! return unless running? debug "deactivating #{self.class}" @vlc.client.disconnect @vlc.server.stop instance.event :player_deactivated end
Tell VLC
to add the given playlist to its queue. @param playlist [Playlist] the playlist to add @return [void] @note Activates VLC
if not already activated.
# File lib/muzak/player/vlc.rb, line 109 def enqueue_playlist(playlist) activate! unless running? playlist.songs.each do |song| load_song song end end
Get VLC's internal queue. @return [Array<Song>] all songs in VLC's queue @note This includes songs already played. @todo Implement this.
# File lib/muzak/player/vlc.rb, line 121 def list_queue debug @vlc.playlist.to_s danger "this player doesn't support list_queue" # TODO: figure out how to get VLC::Client#playlist to return filenames [] end
Load a song into VLC
. @param song [Song] the song to load @return [void] @api private
# File lib/muzak/player/vlc.rb, line 154 def load_song(song) @vlc.add_to_playlist song.path @vlc.play if Config.autoplay end
Tell VLC
to play the next song in its queue. @return [void] @note Does nothing if the current song is the last.
# File lib/muzak/player/vlc.rb, line 72 def next_song @vlc.next end
Get VLC's currently loaded song. @return [Song, nil] the currently loaded song
# File lib/muzak/player/vlc.rb, line 144 def now_playing return unless playing? Song.new(@vlc.status[:file]) end
Tell VLC
to pause playback. @return [void] @note Does nothing is playback is already paused.
# File lib/muzak/player/vlc.rb, line 56 def pause return unless running? @vlc.pause end
Tell VLC
to begin playback. @return [void] @note Does nothing is playback is already in progress.
# File lib/muzak/player/vlc.rb, line 47 def play return unless running? @vlc.play end
@return [Boolean] whether or not VLC
is currently playing.
# File lib/muzak/player/vlc.rb, line 63 def playing? return false unless running? @vlc.playing? end
Tell VLC
to play the previous song in its queue. @return [void] @note Restarts the song if the current song is the first.
# File lib/muzak/player/vlc.rb, line 79 def previous_song @vlc.previous end
@return [Boolean] whether or not the current instance is running.
# File lib/muzak/player/vlc.rb, line 15 def running? !!@vlc&.connected? end
Shuffle VLC's internal queue. @return [void] @todo Implement this.
# File lib/muzak/player/vlc.rb, line 131 def shuffle danger "this player doesn't support shuffling (?)" end