Module: Vlc_path

Defined in:
lib/shoes/vlcpath.rb

Class Method Summary collapse

Class Method Details

.check(vlc_p, plug_p) ⇒ Object

Make sure, as best we can that dlload() will succeed Mostly a windows path problem


69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/shoes/vlcpath.rb', line 69

def check (vlc_p, plug_p)
  return false if ! (File.directory? plug_p)
  have = false
  begin 
    Dir.chdir(File.dirname(vlc_p)) do |p|
      if File.exist? File.basename(vlc_p)
        have = true
      end
    end
  rescue
    have = false
  end
  return have
end

.load(yamlp = nil) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/shoes/vlcpath.rb', line 5

def load (yamlp=nil)
  # do we have a vlc.yaml
  vlc_app_path = nil
  vlc_plugin_path = nil
  mostly_ok = false
  if yamlp && (File.exist? yamlp)
    cfg = YAML.load_file(yamlp)
    vlc_app_path = cfg['vlc_app_path']
    vlc_plugin_path = cfg['vlc_plugin_path']
    mostly_ok = true
  end
  # Look in standard locations
  if !vlc_app_path
    case RUBY_PLATFORM
      when /ming/
        if ENV['ProgramFiles(x86)']
          vlc_app_path = "C:/Program Files (x86)/VideoLAN/VLC/libvlc.dll"
          vlc_plugin_path = "C:/Program Files (x86)/VideoLan/VLC/plugins"
        else
          vlc_app_path = "C:/Program Files/VideoLAN/VLC/libvlc.dll"
          vlc_plugin_path = "C:/Program Files/VideoLan/VLC/plugins"
        end
      when /linux/
        Dir.glob('/usr/lib/libvlc.so*') do |p|
          vlc_app_path = p if ! File.symlink?(p)
        end
        vlc_plugin_path = '/usr/lib/vlc/plugins' if vlc_app_path
      when /darwin/
        Dir.glob('/Applications/VLC.app/Contents/MacOS/lib/libvlc.*dylib') do |p|
          vlc_app_path = p if ! File.symlink?(p)
        end
        vlc_plugin_path = "/Applications/VLC.app/Contents/MacOS/plugins" if vlc_app_path
    end

    begin 
      # it's a Windows Ruby thing with the spaces in the path
      Dir.chdir(File.dirname(vlc_app_path)) do |p|
        mostly_ok = File.exist? File.basename(vlc_app_path)
      end
    rescue 
      #puts "vlc not at standard location "
      vlc_app_path = nil
      mostly_ok = false
    end
  end
  if vlc_app_path && vlc_plugin_path && mostly_ok
      ENV['VLC_APP_PATH'] = vlc_app_path
      ENV['VLC_PLUGIN_PATH'] = vlc_plugin_path
      #puts "Yaml load: #{vlc_app_path} #{vlc_plugin_path}"
  end
end

.save(yamlp) ⇒ Object

save env vars to vlc.yaml


59
60
61
62
63
64
# File 'lib/shoes/vlcpath.rb', line 59

def save(yamlp)
  tree = { "vlc_app_path" => "#{ENV['VLC_APP_PATH']}",
    "vlc_plugin_path" => "#{ENV['VLC_PLUGIN_PATH']}"
  }
  File.open(yamlp, 'w') {|f| YAML.dump(tree, f) }
end