Skip to content
Browse files

id3 example

  • Loading branch information...
1 parent ba5b44d commit 3a565fd7248df3f91fb3edb3de7cb77a5a803731 @gagle committed
Showing with 1 addition and 111 deletions.
  1. +1 −111 examples/id3-v1.1/id3-v1.1.js
View
112 examples/id3-v1.1/id3-v1.1.js
@@ -158,114 +158,4 @@ r.on ("error", function (error){
})
.close ();
}
-});
-
-
-
-
-
-
-/*
-var close = function (binaryReader, error){
- if (error) console.log (error);
-
- binaryReader.close (function (error){
- if (error) console.log (error);
- });
-};
-
-var printTags = function (){
- console.log ("Title:\t\t" + tags.title);
- console.log ("Artist:\t\t" + tags.artist);
- console.log ("Album:\t\t" + tags.album);
- console.log ("Year:\t\t" + tags.year);
- console.log ("Comment:\t" + tags.comment);
- console.log ("Track:\t\t" + tags.track);
- console.log ("Genre:\t\t" + genres[tags.genre]);
-};
-
-
-
-
-
-/*
-//Default buffer if not specified is 16KB. Try changing this value, the result should be the same.
-var bufferSize = 16384;
-
-//The window starts from byte 127 starting from the end of the file, in our case the byte at the
-//offset 0240, value 54. The end limit is automatically set, it's the file size minus 1, offset
-//02BF, value 89
-new BinaryReader ("id3v1.1.mp3", { bufferSize: bufferSize, start: 127, fromEnd: true })
- //The text has ASCII encoding so it's safe to read 1 byte per chararacter
- //Check if TAG is present, if so the music file has ID3v1/v1.1 tags
- .read (3, function (error, bytes, bytesRead){
- if (error) return close (this, error);
-
- if (bytes.toString ("ascii") !== "TAG"){
- console.log ("The music file doesn't have ID3v1/v1.1 tags.");
- close (this);
- return;
- }
-
- //Read title
- this.read (30, function (error, bytes, bytesRead){
- if (error) return close (this, error);
-
- tags.title = bytes.toString ("ascii");
-
- //Read artist
- this.read (30, function (error, bytes, bytesRead){
- if (error) return close (this, error);
-
- tags.artist = bytes.toString ("ascii");
-
- //Read album
- this.read (30, function (error, bytes, bytesRead){
- if (error) return close (this, error);
-
- tags.album = bytes.toString ("ascii");
-
- //Read year
- this.read (4, function (error, bytes, bytesRead){
- if (error) return close (this, error);
-
- tags.year = bytes.toString ("ascii");
-
- //Read comment
- this.read (29, function (error, bytes, bytesRead){
- if (error) return close (this, error);
-
- tags.comment = bytes.toString ("ascii");
- var isLastCharNullByte = bytes[28] === 0x00;
-
- //Read track
- this.read (1, function (error, bytes, bytesRead){
- if (error) return close (this, error);
-
- if (isLastCharNullByte){
- tags.track = bytes.toString ("ascii");
- }else{
- tags.comment += bytes.toString ("ascii");
- }
-
- //Read genre
- this.read (1, function (error, bytes, bytesRead){
- if (error) return close (this, error);
-
- tags.genre = bytes[0];
-
- //We should have reached the end of the window/file
- if (this.isOffsetOutOfWindow ()){
- console.log ("All tags has been read successfully!\n");
- printTags ();
- }
-
- close (this);
- });
- });
- });
- });
- });
- });
- });
- });*/
+});

0 comments on commit 3a565fd

Please sign in to comment.
Something went wrong with that request. Please try again.