音乐分享 html,html5 audio之分享版音乐播放器
时间: 2023-09-04 17:10:03 浏览: 143
好的,这是一个基于 HTML5 的音乐分享播放器示例:
```html
<!DOCTYPE html>
<html>
<head>
<title>音乐分享播放器</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
h1 {
text-align: center;
margin-top: 30px;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
audio {
width: 100%;
margin-top: 30px;
}
.controls {
display: flex;
align-items: center;
justify-content: center;
margin-top: 20px;
}
button {
background-color: #4CAF50;
color: white;
border: none;
padding: 10px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
cursor: pointer;
margin: 5px;
border-radius: 4px;
}
button:hover {
background-color: #3e8e41;
}
</style>
</head>
<body>
<h1>音乐分享播放器</h1>
<div class="container">
<audio controls>
<source src="https://example.com/music.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<div class="controls">
<button onclick="playMusic()">播放</button>
<button onclick="pauseMusic()">暂停</button>
</div>
</div>
<script>
var audio = document.querySelector('audio');
function playMusic() {
audio.play();
}
function pauseMusic() {
audio.pause();
}
</script>
</body>
</html>
```
你只需要将 `https://example.com/music.mp3` 替换为你自己的音乐文件链接即可,这个播放器支持在 PC 和移动设备上播放音乐,同时也提供了基本的播放控制按钮。希望这个示例能够帮到你!
阅读全文