| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fd02c55 commit 9d26805
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,6 +47,11 @@ ID3.loadTags("filename.mp3", function() { | |||
| 47 | 47 | }, | |
| 48 | 48 | {tags: ["comment", "track", "lyrics"]}); | |
| 49 | 49 | ``` | |
| 50 | + Example | ||
| 51 | + ------- | ||
| 52 | + See `/example` for additional information. | ||
| 53 | + Besides open http://www.aadsm.net/libraries/id3/ for a live example. | ||
| 54 | + | ||
| 50 | 55 | Documentation | |
| 51 | 56 | ------------- | |
| 52 | 57 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,42 @@ | |||
| 1 | + <!DOCTYPE html> | ||
| 2 | + <html> | ||
| 3 | + <head> | ||
| 4 | + <meta charset="utf-8"> | ||
| 5 | + <title>Javascript ID3 Reader</title> | ||
| 6 | + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | ||
| 7 | + <meta name="description" content=""> | ||
| 8 | + <meta name="viewport" content="width=device-width"> | ||
| 9 | + <script src="../dist/id3-minimized.js" type="text/javascript"></script> | ||
| 10 | + | ||
| 11 | + </head> | ||
| 12 | + | ||
| 13 | + <body> | ||
| 14 | + <div> | ||
| 15 | + <p id="title"></p> | ||
| 16 | + <p id="artist"></p> | ||
| 17 | + <img id="picture" src="" alt= "picture extracted from ID3" /> | ||
| 18 | + </div> | ||
| 19 | + | ||
| 20 | + <script> | ||
| 21 | + //sample.mp3 sits on your domain | ||
| 22 | + ID3.loadTags("sample.mp3", function() { | ||
| 23 | + var tags = ID3.getAllTags("sample.mp3"); | ||
| 24 | + console.log(tags); | ||
| 25 | + document.getElementById('title').innerHTML = tags.title; | ||
| 26 | + document.getElementById('artist').innerHTML = tags.artist; | ||
| 27 | + var image = tags.picture; | ||
| 28 | + if (image) { | ||
| 29 | + //Caution: old browsers (IE) don't implement Base64 | ||
| 30 | + //see N. Zakas for fallback: | ||
| 31 | + //https://github.com/nzakas/computer-science-in-javascript/tree/master/encodings/base64 | ||
| 32 | + var base64 = "data:" + image.format + ";base64," + Base64.encodeBytes(image.data); | ||
| 33 | + document.getElementById('picture').setAttribute('src',base64); | ||
| 34 | + } else { | ||
| 35 | + document.getElementById('picture').style.display = "none"; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + }, | ||
| 39 | + {tags: ["title","artist","picture"]}); | ||
| 40 | + </script> | ||
| 41 | + </body> | ||
| 42 | + </html> | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments