forked from aadsm/JavaScript-ID3-Reader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
141 lines (116 loc) · 5.01 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
JavaScript ID3 Reader
=====================
This library was originally made by Jacob Seidelin using ID3v1 for demo'ing his BinaryAjax library [http://www.nihilogic.dk/labs/id3/].
It was then extended by me (António Afonso) to include the ID3v2 tag specification [http://www.id3.org/id3v2.4.0-structure], while I was working at Opera Software, in the context of the Unite Media Player application which was developed using server side JavaScript.
Joshua Kifer implemented the tag reader for the QuickTime metadata information found in aac files.
A new BufferedBinaryFile was created that extends BinaryFile in a way that only required data will be downloaded from the server. This makes it possible to read tag structures such as the Quicktime metadata without having to download the entire file as it was happening in previous versions of this library.
Demo: http://www.aadsm.net/libraries/id3/#demo
Technical Information
---------------------
This library will only download the relevant data from the mp3 file whenever the webserver supports the HTTP Range feature, otherwise the entire file will be downloaded at the cost of degrading the performance of the library.
Another caveat is on the Opera browser, since it lacks support for setting the Range header, the entire file will be downloaded.
This library is not complete and there is still some features missing and/or going on:
* Unsynchronisation support
* CommonJS support
* Support for other types of charsets, at the moment only latin1, UTF-8 and UTF-16 are supported, these are the ones defined in the specification. However, the usage of local charsets has been common for a long time specially in Russia, Japan and China. This support can be achieved using [chardet](http://github.com/aadsm/jschardet) and a proper string reader function.
How To Use It
-------------
In its simplest form:
`ID3.loadTags("filename.mp3", function() {
var tags = ID3.getAllTags(filename);
alert(tags.artist + " - " + tags.title + ", " + tags.album);
});`
by specifying specific tags:
`ID3.loadTags("filename.mp3", function() {
var tags = ID3.getAllTags(filename);
alert(tags.COMM.data + " - " + tags.TCON.data + ", " + tags.WXXX.data);
},
{tags: ["COMM", "TCON", "WXXX"]});`
or even by specifying shortcuts instead of cryptic tags:
`ID3.loadTags("filename.mp3", function() {
var tags = ID3.getAllTags(filename);
alert(tags.comment + " - " + tags.track + ", " + tags.lyrics);
},
{tags: ["comment", "track", "lyrics"]});`
Documentation
-------------
`ID3.loadTags(url, cb, [options])`
`url` - The URL of the mp3 file to read, this must reside on the same domain (document.domain).
`cb` - The callback function to invoke when the tags are loaded.
`options` - Optional parameters.
`options.tags` - The array of tags and/or shortcuts to read from the ID3 block. Default value is: `["title", "artist", "album", "track"]`
`options.dataReader` - The function used to create the data reader out of a url. It receives (`url`, `success`: callback function that returns the data reader, `fail`: callback function to inform an error setting up the reader). By default it will be BufferedBinaryAjax.
`ID3.getAllTags(url)`
`url` - The URL of the mp3 file to read, this must be the same value given to `ID3.loadTags()`.
`return value` - This function will return the following object structure, for IDv1:
{
version: "1.1",
title: string,
artist: string,
album: string,
year: string,
comment: string,
track: string,
genre: string
}
for ID3v2:
{
version: "2.<major>.<revision>",
major: integer,
revision: integer,
flags: {
unsynchronisation: boolean,
extended_header: boolean,
experimental_indicator: boolean
},
size: integer,
<frame id>*: {
id: integer,
size: integer,
description: string,
data: <frame structure>
},
<shortcut>*: pointer to <frame id>.data
}
for AAC:
{
album: string,
artist: string,
year: integer,
title: string,
genre: string,
track: integer,
composer': string,
encoder: string,
copyright: string,
picture: {
format: string,
data: bytes[]
},
grouping: string,
keyword: string,
lyrics: string,
genre: string
}
### Currently supported frames on ID3:
* APIC/PIC: Attached picture
* COMM/COM: Comments
* PCNT/CNT: Play counter
* T*: Text frames
* USLT/ULT: Unsychronized lyric/text transcription
### Shortcuts:
* title: TIT2/TT2
* artist: TPE1/TP1
* album: TALB/TAL
* year: TYER/TYE
* comment: COMM/COM
* track: TRCK/TRK
* genre: TCON/TCO
* picture: APIC/PIC
* lyrics: USLT/ULT
A comprehensive list of all tags defined in the specification can be found [here](http://www.id3.org/id3v2.3.0#head-e4b3c63f836c3eb26a39be082065c21fba4e0acc)
Authors
-------
* Jacob Seidelin
* António Afonso
* Joshua Kifer