本文介绍了如何制作单击时播放音频的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试实现一个播放音频的按钮.我不想有滑块.
I am trying to implement a button that plays audio. I don't want to have the slider.
反正有没有要摆脱的滑块,或者使用按钮的图像呢?
Is there anyway to rid of the slider, or maybe use an image of a button instead?
当前代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Music</title>
<style type="text/css">
body {
color:transparent;
}
</style>
</head>
<body onLoad="RandomSong();">
<audio id="content" src="background1.mp3" controls></audio>
<script>
function RandomSong() {
var Music = ["background1.mp3","background2.mp3","background3.mp3","background4.mp3","background5.mp3"];
var randomCode = Math.floor(Math.random()*Music.length);
document.getElementById("content").value = "mp3=" + Music[randomCode] + "&showslider=0&width=5&loop=1&autoplay=0&volume=50";
}
</script>
</body>
</html>
推荐答案
我正在为孩子们制作文字游戏,我一直在玩这段代码,内容涉及如何制作在被点击时播放音频的图像.我希望这能帮到您我正在使用Notepad ++,此代码可在Google Chome中使用
I'm into making word games for kids, I been playing around with this code for How to make an image that plays audio when cicked. I hope this will help youI'm using Notepad++ this code works in Google Chome
<!DOCTYPE html>
<html>
<script>
var audio1 = new Audio("/Sound 1/Samples 1Sounds/CAT.wav ");
audio.oncanplaythrough = function(){}
audio.onended = function(){}
</script>
<input type="image" id="myimage"style="height:200px;width:200px;"src="/Picture 1/Samples Pictures/cat.jpg"
onclick="audio1.play()">
<script>
var audio2 = new Audio("/Sound 1/Samples 1Sounds/dog.wav ");
audio.oncanplaythrough = function(){}
audio.onended = function(){}
</script>
<input type="image" id="myimage" style="height:200px;width:200px;"src="/Picture 1/Samples Pictures/dog.jpg"
onclick="audio2.play()">
</html>
这篇关于如何制作单击时播放音频的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!