E8以上的用audio,IE8或者以下都用embed
audio:
该标签含有的属性
src 引入文件的路径
controls 是否对用户开启权限,让用户获得一个音频播放的操作
loop 开启循环播放
autoplay 开启自动播放
代码示范: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>mp3音频</title> </head> <body> <h1>不要动!!!!!!</h1> <!-- 音频文件 --> <img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fitem%2F201811%2F18%2F20181118205113_lffkt.thumb.400_0.gif&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1636731875&t=31473b6ce6a6188ffd3c3f71cafacc81" alt="童年"> <!-- 可以不直接指定路径,在标签指定多个source可以很好的解决浏览 器兼容性的问题。 --> <audio controls loop> <!-- 支持IE8以上的 --> <source src="./source/张磊 - 寻 (Live).mp3"> <!-- 支持IE8及以下 --> <embed src="./source/张磊 - 寻 (Live).mp3" type="audio/mp3"> </audio> </body> </html>
视频引入标签
使用video标签和audio大致一样
代码实现
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2Fd317144d3c9c4bb53b663ead9a9ebe8a5818a5cc1d2d96-Q4ZkBx_fw658&refer=http%3A%2F%2Fhbimg.b0.upaiyun.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1636787160&t=43c32de0246ad3ea07326eb914e2def6" alt=""> <br><br><br><br><br> <img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2F941ce32d341704d3e501e24503eedc99afe9e7b94af1a-Y6Pwe3_fw658&refer=http%3A%2F%2Fhbimg.b0.upaiyun.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1636787206&t=bce79b3709509f55f8d0540d8b271945" alt=""> <!-- <video controls> <source src="../html/source/1-1认识主机及基本外设.mp4"> <embed src="../html/source/1-1认识主机及基本外设.mp4" type="video/mp4"> </video> --> <iframe frameborder="0" src="https://v.qq.com/txp/iframe/player.html?vid=d0040cqqgtz" allowFullScreen="true" width="500" height="500"></iframe> </body> </html>