Skip to content

Instantly share code, notes, and snippets.

@gabriel-lopez
Created July 13, 2018 11:19
Show Gist options
  • Select an option

  • Save gabriel-lopez/3432099335632021bf5c85899ce3572b to your computer and use it in GitHub Desktop.

Select an option

Save gabriel-lopez/3432099335632021bf5c85899ce3572b to your computer and use it in GitHub Desktop.
Utility class used to detect the location of VLC and launch a stream.
public static class VLCHelper
{
private const string KEY = @"SOFTWARE\VideoLAN\VLC";
public static void StartStream(string url)
{
string path = null;
// Checking 32-Bit VLC Install
RegistryKey localKey32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
localKey32 = localKey32.OpenSubKey(KEY);
if (localKey32 != null)
{
path = localKey32.GetValue(null).ToString();
}
// Checking 64-Bit VLC Install
RegistryKey localKey64 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
localKey64 = localKey64.OpenSubKey(KEY);
if (localKey64 != null)
{
path = localKey64.GetValue(null).ToString();
}
if (path == null)
{
MessageBox.Show("VLC not found !", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
StartVlc(path, url);
}
}
private static void StartVlc(string path, string url)
{
var vlc = new Process
{
StartInfo =
{
FileName = path,
Arguments = "-vvv " + url,
}
};
vlc.Start();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment