在HTML网站的MP3播放器 [英] mp3 player in HTML website
问题描述
我想插入一个简单的MP3播放器到我的网站。 Mp3播放器必须只有2个按钮(播放和暂停)。
我发现这个: http://www.schillmania.com/projects/soundmanager2/ ,它看起来不错,但我不能让它有这两个按钮。任何人都可以帮助我找到一种以这种方式插入mp3播放器的方法吗?
我正在做一个关于这个主题的研究几个月前在游戏中播放声音,SoundManager是使用JavaScript播放音频的更简单的方法。
第一种方法:如果您转到文档,您会看到 SoundManager拦截了MP3链接的点击,并以内联方式播放。该脚本为链接分配额外的CSS类以指示其状态(播放/暂停等)。
< a href = /mp3/foo.mp3title =播放声音class =sm2_button> Play Link< / a>
检查 b 如果您想使用个性化按钮而不是链接,图片或任何其他html元素,则可以使用 加载声音: 按钮: 您可以在 API上找到更多信息 I want insert a simple mp3 player into my website. The Mp3 player must have just 2 buttons (play and pause). I found this: http://www.schillmania.com/projects/soundmanager2/ and it seems nice but I could not make it have those two buttons. Can anyone help me find a way to insert an mp3 player in this way? I was doing a research about the subject few months ago for play sound in a game, and SoundManager is the easier way to play audio using JavaScript. If you go to the documentation, you will see that SoundManager intercepts clicks to MP3 links and plays them inline. The script assigns additional CSS classes to the links to indicate their state (playing/paused, etc.) Check demo and more info If you want to use personalized buttons instead of links, or images, or any other html element, you can use the Loading the sound: The buttons: You can found more info on the API 这篇关于在HTML网站的MP3播放器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! onClick
事件播放/暂停声音,例如:
< script>
soundManager.onready(function(){
soundManager.createSound({id:'mySound1',url:'/ audio / foo.mp3'});
} );
< / script>
< button id =playonclick =soundManager.play('mySound1'); return false>播放按钮< / button>
< button id =pauseonclick =soundManager.pause('mySound1'); return false>暂停按钮< /按钮>
First way:
<a href="/mp3/foo.mp3" title="Play sound" class="sm2_button">Play Link</a>
Second way
onClick
event to play/pause sound, for example:<script>
soundManager.onready(function() {
soundManager.createSound({id:'mySound1',url:'/audio/foo.mp3'});
"
});
</script>
<button id="play" onclick="soundManager.play('mySound1');return false">Play Button</button>
<button id="pause" onclick="soundManager.pause('mySound1');return false">Pause Button</button>