diff --git a/vlc/open_windows.go b/vlc/open_windows.go index 2c1ec2a..002f440 100644 --- a/vlc/open_windows.go +++ b/vlc/open_windows.go @@ -3,10 +3,30 @@ package vlc import ( + "os" "os/exec" ) func open(url string) error { - cmd := exec.Command(`C:\Program Files\VideoLAN\VLC\vlc.exe`, url) + vlcPath, err := getVlcPath() + if err != nil { + return err + } + cmd := exec.Command(vlcPath, url) return cmd.Run() } + +const ( + vlcPath64 = `C:\Program Files\VideoLAN\VLC\vlc.exe` + vlcPath32 = `C:\Program Files (x86)\VideoLAN\VLC\vlc.exe` +) + +func getVlcPath() (string, error) { + if _, err := os.Stat(vlcPath64); err == nil { + return vlcPath64, nil + } + if _, err := os.Stat(vlcPath32); err == nil { + return vlcPath32, nil + } + return "", os.ErrNotExist +}