1. controls自带效果
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> </head> <body> <audio src="raw/1.mp3" controls="controls"></audio> </body> </html>
2. 自定义
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> </head> <body> <button id="button" onclick="p()">播放</button> <audio id="music" src="raw/1.mp3">浏览器不支持此音频</audio> <script> var music = document.getElementById("music"); var button = document.getElementById("button"); function p(){ if(music.paused){ music.play(); button.innerHTML = "暂停"; } else{ music.pause(); button.innerHTML = "播放"; } } </script> </body> </html>
3. 编解码工具
FFmpeg.org
<1>进去需要转码文件的文件夹
<2>ffmpeg路径 -i 需要转码文件名及后缀 -acodec libvorbis 想转成的文件及后缀
4. 视频
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> </head> <body> <video controls="controls"> //引入两个视频格式是以防浏览器不支持 <source src="raw/3.mp4"> <source src="raw/3.ogg"> 您的浏览器不支持 </video> </body> </html>