Defintions for musicmetadata package (#10841)

* Add Music Metadata

* Fix some errors
This commit is contained in:
Xavier Stouder
2016-08-30 21:21:56 +09:00
committed by Masahiro Wakame
parent c9848c3240
commit ff8b4983fa
2 changed files with 58 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
/// <reference path="../node/node.d.ts" />
/// <reference path="./musicmetadata.d.ts" />
import * as fs from "fs";
import * as mm from "musicmetadata";
mm(fs.createReadStream("hype-train.mp3"), (err: Error, metadata: MM.Metadata) => {
if (err) throw err;
console.log(`Parsed song ${metadata.title}`);
});
+48
View File
@@ -0,0 +1,48 @@
// Type definitions for musicmetadata 2.0.4
// Project: https://www.npmjs.com/package/musicmetadata
// Definitions by: Xavier Stouder <https://github.com/Xstoudi>
// Definitions: https://github.com/DefinitelyTyped/
/// <reference path="../node/node.d.ts" />
declare module "musicmetadata" {
import {Readable} from "stream";
import {EventEmitter} from "events";
function mm(readStream: Readable, callback: (err: Error, metadata: MM.Metadata) => void): EventEmitter;
function mm(readStream: Readable, options: MM.Options, callback: (err: Error, metadata: MM.Metadata) => void): EventEmitter;
namespace mm { }
export = mm;
}
declare namespace MM {
export interface Options {
duration: boolean;
fileSize: number;
}
export interface Metadata {
artist: string[];
album: string;
albumartist: string[];
title: string;
year: string;
track: NoOf;
disk: NoOf;
genre: string;
picture: Picture[];
duration: number;
}
export interface NoOf {
no: number;
of: number;
}
export interface Picture {
format: string;
data: Buffer;
}
}