JS解析MP3获取歌曲信息--ID3 Reader

ID3 Reader 是一款可以在前台或者后台(nodejs)解析MP3曲目信息(前提是含有这些信息)的工具

官方demo 源码下载 全英文文档

用法示例

1,基本用法

//In its simplest form:
ID3.loadTags("filename.mp3", function() {
    var tags = ID3.getAllTags(filename);
    alert(tags.artist + " - " + tags.title + ", " + tags.album);
});

2,特殊用法

//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"]});

3,文档及API

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
}

and 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
}
Currently supported frames:

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

备注:留待再更新编辑

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: vue-qrcode-reader是一个基于Vue.js的条形码扫描组件。它为用户提供了在网页上扫描条形码的功能。 使用vue-qrcode-reader,我们需要先安装并导入组件。然后,我们可以在Vue的模板中使用组件,并通过设定相应的参数来调整扫描的设置。 该组件支持从摄像头扫描条形码,并可以将扫描到的条形码数据在网页展示出来。我们可以通过捕获组件的事件来获取扫描到的条形码数据,并进行后续的处理。 在使用vue-qrcode-reader的过程中,我们可以自定义组件的样式、设置摄像头的类型、调整扫描的精度等。此外,组件还提供了一些其他的参数,如自动开始扫描、扫描完成后是否暂停等,以便根据实际需求进行相应的调整。 使用vue-qrcode-reader可以方便地在Vue项目中实现条形码的扫描功能。它简化了扫描条形码的开发过程,提高了用户体验,并可以应用于各种需要条形码扫描的场景,如电商购物车、门禁系统等。 ### 回答2: vue-qrcode-reader是一个用于Vue.js的条形码扫描器插件。它基于QuaggaJS库,并提供简单易用的接口,让我们能够在Vue.js应用程序中轻松地集成条形码扫描功能。 使用vue-qrcode-reader非常简便。首先,我们需要安装该插件,可以在命令行中运行`npm install vue-qrcode-reader`来进行安装。安装完成后,可以在Vue组件中引入并注册该插件。 在使用vue-qrcode-reader之前,我们需要在页面中准备一个用于显示扫描结果的容器元素。可以使用一个`div`元素,并在其上绑定一个自定义的`class`或`id`,以便在Vue组件中引用。 然后,在Vue组件中,我们需要导入vue-qrcode-reader插件,并在`components`选项中进行注册。然后,我们可以在组件的`template`中使用插件提供的`Scanner`组件,来实现条形码的扫描功能。 在`Scanner`组件中,我们可以使用`@scan-success`事件来监听扫描成功的回调函数,并处理扫描到的条形码数据。我们还可以通过设置`@picker-active-red-line-color`属性来改变扫描框的红色边线颜色,以及使用`@activate-vibrate`属性来设置设备在扫描时是否震动反馈。 最后,在Vue组件中,我们可以使用`this.$refs.scanner.start`方法来启动条形码扫描,使用`this.$refs.scanner.stop`方法来停止条形码扫描。 总结而言,vue-qrcode-reader是一个方便易用的Vue.js条形码扫描器插件,可以轻松地集成到Vue.js应用程序中,实现条形码的扫描功能。 ### 回答3: vue-qrcode-reader 是一款基于 Vue.js 的扫码组件,可以用于扫描条形码。它使用了浏览器的摄像头,通过扫描条形码获取条形码的信息。 使用 vue-qrcode-reader 很简单,只需要在 Vue.js 的项目中导入该组件,并在需要扫描条形码的地方添加该组件即可。通过调用组件的方法,可以解析获取扫描到的条形码信息。 在使用 vue-qrcode-reader 的时候,可以根据需要进行设置,如配置是否启用闪光灯、设置摄像头的分辨率等。扫描到条形码后,可以通过回调函数获取到扫描到的条形码的内容。 vue-qrcode-reader 提供了一套功能完善的 API,可以方便地进行二维码的扫描和解析。同时,它还支持多种条形码的解析,如 EAN、UPC、Code39 等。 总的来说,vue-qrcode-reader 是一款方便实用的扫码组件,可以在 Vue.js 项目中轻松实现条形码的扫描功能,为用户提供更加便捷的条形码操作体验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值