| 1 | // Copyright 2013 Google Inc. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package taglib |
| 16 | |
| 17 | import ( |
| 18 | "fmt" |
| 19 | "os" |
| 20 | "strings" |
| 21 | _ "testing" |
| 22 | ) |
| 23 | |
| 24 | func ExampleDecode() { |
| 25 | f, err := os.Open("testdata/BeatThee.mp3") |
| 26 | if err != nil { |
| 27 | panic(err) |
| 28 | } |
| 29 | fi, err := f.Stat() |
| 30 | if err != nil { |
| 31 | panic(err) |
| 32 | } |
| 33 | tag, err := Decode(f, fi.Size()) |
| 34 | if err != nil { |
| 35 | panic(err) |
| 36 | } |
| 37 | |
| 38 | fmt.Println("Title:", strings.TrimSpace(tag.Title())) |
| 39 | fmt.Println("Artist:", strings.TrimSpace(tag.Artist())) |
| 40 | fmt.Println("Album:", strings.TrimSpace(tag.Album())) |
| 41 | fmt.Println("Track:", tag.Track()) |
| 42 | |
| 43 | // Output: |
| 44 | // Title: Beat Thee |
| 45 | // Artist: Alexander Nakarada |
| 46 | // Album: Complete Discography (CC BY Attribution 4.0) |
| 47 | // Track: 189 |
| 48 | } |