如何在javascript中获取音频文件的名称 [英] How do I get the name of an audio file in javascript

查看:172
本文介绍了如何在javascript中获取音频文件的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,我使用新的Audio()为我的js项目添加了一个音频(一首歌),我可以播放



的歌曲,但我不知道如何获取音频文件名。



对js来说真是个新手,每天我的脑子都被​​炸掉XD,



我尝试了什么:



Hey guys,i added an audio(a song) to my js project using new Audio(), i can play the

song, but i dont know how to get the audio file name.

am really new to js and everyday my mind gets blown XD,

What I have tried:

var audio = new Audio("mkto-american-dream-video.mp3");
audio.play();
console.log(audio.name);

推荐答案

W3学校是查看任何特定HTML元素的各种属性的好地方 HTML音频标签 [ ^ ]

不幸的是,音频元素似乎无法检索来自文件的ID3信息,包含标题,专辑,艺术家等。



现在有好消息 - 有javascript库可用,有能力阅读这些信息;只搜索JavaScript ID3,您应该找到一些关于该主题的库和一些讨论
W3 Schools is a good place to see what the various attributes are for any particular HTML element HTML audio tag[^]
Unfortunately the Audio element does not appear to have the ability to retrieve the ID3 information from the file, which is what contains the Title, Album, Artist, etc.

Now for the good news- there are javascript libraries available which have the ability to read this information; just search for JavaScript ID3 and you should find some libraries and a few discussions on the topic


这篇关于如何在javascript中获取音频文件的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆