I am trying to play a video in Windows media player through my code. The path is:
C:\Program Files (x86)\Windows Media Player\wmplayer.exe
If I hardcode it,
string filePath = System.IO.Path.Combine (Application.streamingAssetsPath, "Demo.mp4");
Process proc = new Process();
proc.StartInfo.FileName = @"C:\Program Files (x86)\Windows Media Player\wmplayer.exe";
proc.StartInfo.Arguments = "\"" + filePath + "\"";
proc.Start ();
I can play the video. But I want to use the path which is universal for all the machines. So after going through this link Programmatically detect if Windows Media Player is installed, I re-wrote my code to:
private string makePath;
RegistryKey myKey;
makePath = @"HKLM\Software\Microsoft\Active Setup\Installed Components\{22d6f312-b0f6-11d0-94ab-0080c74c7e95}";
myKey = Registry.LocalMachine.OpenSubKey (makePath);
IEnumerator Example ()
{
if (myKey == null) {
print ("No Windows Media Player Installed");
} else {
proc.StartInfo.FileName = makePath;
proc.StartInfo.Arguments = "\"" + filePath + "\"";
proc.Start ();
}
and calling this function somewhere But then myKey appears to be null. Is the path correct which I have mentioned here or what have to be made in order to get the video played?