FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add html example. Update README accordingly · lapsio/JavaScript-ID3-Reader@9d26805 · GitHub

Commit 9d26805

Browse files
authored andcommitted
Add html example. Update README accordingly
1 parent fd02c55 commit 9d26805

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ ID3.loadTags("filename.mp3", function() {
4747
},
4848
{tags: ["comment", "track", "lyrics"]});
4949
```
50+
Example
51+
-------
52+
See `/example` for additional information.
53+
Besides open http://www.aadsm.net/libraries/id3/ for a live example.
54+
5055
Documentation
5156
-------------
5257

‎example/index.html‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff 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>

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL