Use html to implement an audio playback code

零下一度
Release: 2017-04-22 16:01:14
Original
12157 people have browsed it

Player with controls

html<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>播放音频</title>
</head>
<body>
<audio src="raw/1.mp3" controls="controls">你的浏览器不支持</audio>
</body>
</html>
Copy after login
Copy after login

The player is not visible, use buttons to control playback

html<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>播放音频</title>
</head>
<body>
<button onclick="clickA()">播放/暂停</button>
<audio id="audio" src="raw/1.mp3">你的浏览器不支持</audio>
<script>
    var a=document.getElementById("audio");
    function clickA(){
        if(a.paused){
            a.play();
        }else{
            a.pause();
        }
    }
</script>
</body>
</html>
Copy after login
Copy after login

Player with controls

html<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>播放音频</title>
</head>
<body>
<audio src="raw/1.mp3" controls="controls">你的浏览器不支持</audio>
</body>
</html>
Copy after login
Copy after login

The player is not visible, use buttons Control playback

html<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>播放音频</title>
</head>
<body>
<button onclick="clickA()">播放/暂停</button>
<audio id="audio" src="raw/1.mp3">你的浏览器不支持</audio>
<script>
    var a=document.getElementById("audio");
    function clickA(){
        if(a.paused){
            a.play();
        }else{
            a.pause();
        }
    }
</script>
</body>
</html>
Copy after login
Copy after login


The above is the detailed content of Use html to implement an audio playback code. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!