我已经完成了代码。它从用户提供者网址播放mp3。但它正在加载完整的网址作为标题。有没有办法让它只加载mp3标题?
我还希望它在<p>
标签中显示标题。我需要帮助。
function setAudio() {
var url = document.getElementById('url').value;
var audioPlayer = document.getElementById('audioplayer');
audioPlayer.src = url;
}
function loadtitle() {
var title = document.getElementById('url').value;
var loadtitle = document.getElementById('loadtitle');
loadtitle.value = title;
}
<center class="lolmanaudio">
<input type="text" value="Title Here" style="border-width: 1px; border-style: solid; width: 90%; padding: 8px 15px 8px 30px;" id="loadtitle"/>
<br>
<button onclick="loadtitle()">Load Title</button>
<input type="text" id="url"/>
<button onclick="setAudio()">Load Audio File</button>
<h5><a href="http://blog.grplusbd.net">GR+ Bangladesh</a></h5>
<audio id="audioplayer" src="" controls preload="metadata">Your browser does not support the audio element.</audio>
<br>...
</center>
答案 0 :(得分:0)
您可以使用此简单代码检查文件扩展名
var url = "http://example.com/audio/file.mp3";
var url2 = "http://example.com/audio/file.wav";
if (url.match(/.mp3$/g))
alert("mp3");
if (url2.match(/.mp3$/g))
alert("wav");
&#13;