---
title: "网页嵌入mp3音乐"
author: "submaze"
date: "2014-05-29T16:05:42Z"
tags: []
categories: ["Web前端"]
slug: "mp3"
draft: false
lastmod: "2014-05-29T16:05:42Z"
id: 2073492
url: "https://submaze.iteye.com/blog/2073492"
---

```html


<!--声音-->
<audio id="v1" controls="controls" height="100" width="100" style=" display:none">
	<source src="music.mp3" type="audio/mp3" />
  <source src="song.ogg" type="audio/ogg" />
  <embed height="100" width="100" src="music.mp3" />
</audio>

<script>
var myVideo=document.getElementById("v1");

function playVid()
  {
  	myVideo.play();
  }
function pauseVid()
  {
  	myVideo.pause();
  }

</script>

<button onClick="playVid()">播放</button>
<button onClick="pauseVid()">暂停</button>


```



参考文档：
HTML5标签介绍：
http://www.w3school.com.cn/tags/html_ref_audio_video_dom.asp
音频播放介绍
http://www.w3school.com.cn/html/html_audio.asp