gpt4 book ai didi

html - 如何制作单击时播放音频的图像

转载 作者:行者123 更新时间:2023-12-02 23:44:39 27 4
gpt4 key购买 nike

我正在尝试实现一个播放音频的按钮。我不想有 slider 。

有没有办法摆脱 slider ,或者使用按钮的图像来代替?

当前代码:

<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] + "&amp;showslider=0&amp;width=5&amp;loop=1&amp;autoplay=0&amp;volume=50";
}
</script>
</body>
</html>

最佳答案

有一个简单的 JQuery 解决方案:

<script type="text/javascript" src="jquery-1.7.1.js"></script>
<script type="text/javascript">
$(document).ready( function() {
$('#track1').click(function(){
$('#wrap').append('<embed id="embed_player" src="audio.wav" autostart="true" hidden="true"></embed>');
});
});
</script>
<img name="track1" src="images/track1.png" width="180" height="180" border="0" id="track1" alt="" />
<div id="wrap">&nbsp;</div>

Src:查看来自@blasteralfred 的类似帖子: Play sound file when image is clicked

关于html - 如何制作单击时播放音频的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33203522/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com