首頁  >  文章  >  web前端  >  HTML 音訊標籤

HTML 音訊標籤

WBOY
WBOY原創
2024-09-04 16:33:471145瀏覽

HTML 5中引入的HTML音訊標籤。此標籤用於將所有音訊檔案新增至HTML頁面。該音訊標籤還添加了音訊控件,如播放、音量、暫停等。在音訊標籤 中,元素用於選擇瀏覽器正在選擇的替代音訊文件,瀏覽器始終選擇第一個識別的格式。我們也可以在

瀏覽器和允許的格式:

Browsers Formats
  MP3 WAV OGG
Edge/IE YES NO NO
Chrome YES YES YES
Firefox YES YES YES
Safari YES YES NO
Opera YES YES YES
瀏覽器

格式

 

MP3 WAV
File Format Media Type
MP3 audio/mpeg
OGG audio/ogg
WAV audio/wav

OGG

邊緣/IE

  • Chrome
  • 火狐
  • Safari

    歌劇

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="ISO-8859-1">
    <title>Audio Tag</title>
    <style type="text/css">
    h1
    {
    color: red;
    text-align: center;
    }
    p
    {
    color: green;
    font-size: 20px;
    border: 2px dotted brown;
    }
    </style>
    </head>
    <body>
    <h1>Audio Tag Introduction</h1>
    <p>HTML audio tag introduced in HTML 5. This tag is used to add all
    audio files to the HTML page. This audio tag also adds audio controls
    like play, volume, pause etc. In audio tag source element is used for
    choose alternative audio files which browser is choosing, browser is
    always choose first recognized format. We can also add text between
    audio and /audio tag but it is not performing audio functionality, it
    is just act as plain text.</p>
    <h1>MP3 Audio Demo from online source</h1>
    <audio controls>
    <source
    src="https://file-examples.com/wp-content/uploads/2017/11/file_example_MP3_700KB.mp3"
    type="audio/mpeg">
    </audio>
    </body>
    </html>

    表> 音訊標籤在 HTML 中如何運作? HTML 音訊的工作原理是基於我們給定的音訊檔案類型以及我們在其中使用的屬性。

    HTML 音訊標籤

    音訊格式與媒體類型:

    檔案格式

    媒體類型
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="ISO-8859-1">
    <title>Audio Tag</title>
    <style type="text/css">
    h1
    {
    color: green;
    text-align: center;
    }
    p
    {
    color: blue;
    font-size: 20px;
    border: 2px solid orange;
    }
    </style>
    </head>
    <body>
    <h1>Audio Tag Introduction</h1>
    <p>HTML audio tag introduced in HTML 5. This tag is used to add all
    audio files to the HTML page. This audio tag also adds audio controls
    like play, volume, pause etc. In audio tag source element is used for
    choose alternative audio files which browser is choosing, browser is
    always choose first recognized format. We can also add text between
    audio and /audio tag but it is not performing audio functionality, it
    is just act as plain text.</p>
    <h1>WAV Audio Demo from online source</h1>
    <audio controls>
    <source
    src="https://file-examples.com/wp-content/uploads/2017/11/file_example_WAV_1MG.wav"
    type="audio/wav">
    </audio>
    </body>
    </html>
    MP3

    音訊/mpeg OGG

    HTML 音訊標籤音訊/ogg

    WAV

    音訊/wav

    表> 屬性
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="ISO-8859-1">
    <title>Audio Tag</title>
    <style type="text/css">
    h1
    {
    color: blue;
    text-align: center;
    }
    p
    {
    color: fuchsia;
    font-size: 20px;
    border: 2px dashed red;
    }
    </style>
    </head>
    <body>
    <h1>Audio Tag Introduction</h1>
    <p>HTML audio tag introduced in HTML 5. This tag is used to add all
    audio files to the HTML page. This audio tag also adds audio controls
    like play, volume, pause etc. In audio tag source element is used for
    choose alternative audio files which browser is choosing, browser is
    always choose first recognized format. We can also add text between
    audio and /audio tag but it is not performing audio functionality, it
    is just act as plain text.</p>
    <h1>OGG Audio Demo from online source</h1>
    <audio controls autoplay>
    <source
    src="https://file-examples.com/wp-content/uploads/2017/11/file_example_OOG_5MG.ogg"
    type="audio/ogg">
    </audio>
    </body>
    </html>
    它們是音訊標籤中的不同屬性。每個屬性都有其要執行的功能。

    以上是HTML 音訊標籤的詳細內容。更多資訊請關注PHP中文網其他相關文章!

  • 陳述:
    本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn