没有SWF文件的HTML音频播放器 [英] HTML Audio Player without SWF File
本文介绍了没有SWF文件的HTML音频播放器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好吧
我有这个例子......它是一个音频播放器列表,但我有一点问题...它打开文件新窗口如何在同一个窗口中制作它??????
CSS文件:
Hi everyone
I have this example...it''s an audio player list but I have a little problem ... it opens the file in new windows how to make it in the same window??????
CSS File:
#playlist,audio{background:#666;width:400px;padding:20px;}
.active a{color:#5DB0E6;text-decoration:none;}
li a{color:#eeeedd;background:#333;padding:5px;display:block;}
li a:hover{text-decoration:none;}
HTML文件:
HTML File:
<audio id="audio" preload="auto" tabindex="0" controls="" type="audio/mpeg">
<source type="audio/mp3" src="http://www.archive.org/download/bolero_69/Bolero.mp3">
Sorry, your browser does not support HTML5 audio.
</audio>
<ul id="playlist">
<li class="active"><a href="http://www.archive.org/download/bolero_69/Bolero.mp3">Ravel Bolero</a></li>
<li><a href="http://www.archive.org/download/MoonlightSonata_755/Beethoven-MoonlightSonata.mp3">Moonlight Sonata - Beethoven</a></li>
<li><a href="http://www.archive.org/download/CanonInD_261/CanoninD.mp3">Canon in D Pachabel</a></li>
<li><a href="http://www.archive.org/download/PatrikbkarlChamberSymph/PatrikbkarlChamberSymph_vbr_mp3.zip">patrikbkarl chamber symph</a></li>
</ul>
JavaScript文件:
JavaScript File:
var audio;
var playlist;
var tracks;
var current;
init();
function init(){
current = 0;
audio = $('audio');
playlist = $('#playlist');
tracks = playlist.find('li a');
len = tracks.length - 1;
audio[0].volume = .10;
playlist.find('a').click(function(e){
e.preventDefault();
link = $(this);
current = link.parent().index();
run(link, audio[0]);
});
audio[0].addEventListener('ended',function(e){
current++;
if(current == len){
current = 0;
link = playlist.find('a')[0];
}else{
link = playlist.find('a')[current];
}
run($(link),audio[0]);
});
}
function run(link, player){
player.src = link.attr('href');
par = link.parent();
par.addClass('active').siblings().removeClass('active');
audio[0].load();
audio[0].play();
}
推荐答案
(' 音频'跨度>);
playlist =
('audio'); playlist =
(' #playlist' );
tracks = playlist.find(' li a');
len = tracks.length - 1 ;
audio [ 0 ]。volume =。 10 ;
playlist.find(' a')。click(功能(e){
e.preventDefault();
link =
('#playlist'); tracks = playlist.find('li a'); len = tracks.length - 1; audio[0].volume = .10; playlist.find('a').click(function(e){ e.preventDefault(); link =
(这);
current = link.parent()。index();
run(link,audio [ 0 ]) ;
});
audio [ 0 ]。addEventListener(' 结束', function (e){
current ++;
if (current == len){
current = 0 ;
link = playlist.find( ' a')[ 0 ];
} else {
link = playlist.find(' a')[current];
}
run(
(this); current = link.parent().index(); run(link, audio[0]); }); audio[0].addEventListener('ended',function(e){ current++; if(current == len){ current = 0; link = playlist.find('a')[0]; }else{ link = playlist.find('a')[current]; } run(
这篇关于没有SWF文件的HTML音频播放器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文