Skip to content

Commit

Permalink
Merge pull request #5 from chrisngyn/fix/fix-not-open-in-vlc
Browse files Browse the repository at this point in the history
Fix not open vlc x86 on windows
  • Loading branch information
chrisngyn authored Feb 7, 2024
2 parents 4ee6140 + 84029bd commit d6352e0
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion vlc/open_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit d6352e0

Please sign in to comment.