PlayPath will play an album or playlist by reading a Spotify URI from a file whose filepath is passed into the function. An error is returned if one is encountered.
(c Client, p string)
| 12 | // function. |
| 13 | // An error is returned if one is encountered. |
| 14 | func PlayPath(c Client, p string) error { |
| 15 | f, err := os.Open(p) |
| 16 | if err != nil { |
| 17 | return err |
| 18 | } |
| 19 | defer f.Close() |
| 20 | |
| 21 | s := bufio.NewScanner(f) |
| 22 | var l string |
| 23 | if s.Scan() { |
| 24 | l = s.Text() |
| 25 | } |
| 26 | |
| 27 | if l == "" { |
| 28 | return fmt.Errorf("unable to read line from path: %s", p) |
| 29 | } |
| 30 | |
| 31 | return PlayUri(c, l) |
| 32 | } |
| 33 | |
| 34 | // PlayURI will play the album or playlist Spotify URI that is passed in to the function. |
| 35 | // An error is returned if one is encountered. |