Class: Sportsflix::Players::VLC::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/sportsflix/players/vlc.rb

Constant Summary collapse

ALTERNATIVE_PLAYER_PATHS =
[
    'vlc',
    '/Applications/VLC.app/Contents/MacOS/VLC',
    '/c/Program Files/VideoLAN/VLC/vlc.exe',
    '/mnt/c/Program Files/VideoLAN/VLC/vlc.exe'
]

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Client

Returns a new instance of Client.



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/sportsflix/players/vlc.rb', line 17

def initialize(options)
  @verbose           = options[:verbose]
  @server_only       = options['server-only']
  @video_player_path = options['video-player-path']
  @proxy_delay       = options['proxy-delay']

  @executor       = Sportsflix::Utils::Executor.new(options)
  @stream_proxies = {
      :default   => Sportsflix::Players::Proxies::Default::Client.new(options),
      :acestream => Sportsflix::Players::Proxies::Acestream::Client.new(options)
  }
end

Instance Method Details

#start(stream) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/sportsflix/players/vlc.rb', line 30

def start(stream)
  proxy = @stream_proxies[stream[:proxy]]

  proxy.stop
  proxy.start

  # Waiting for proxy to start
  puts "Waiting for proxy to start (#{@proxy_delay})..."
  sleep(@proxy_delay)

  stream_final_url = proxy.url(stream[:uri])
  puts "Playing #{stream_final_url}"

  unless @server_only
    video_player = find_video_player
    @executor.run %{#{video_player} #{stream_final_url}}

    proxy.stop
  end
end