Heim  >  Artikel  >  Web-Frontend  >  HTML-Audio-Tag

HTML-Audio-Tag

WBOY
WBOYOriginal
2024-09-04 16:33:471145Durchsuche

HTML-Audio-Tag eingeführt in HTML 5. Dieses Tag wird verwendet, um alle Audiodateien zur HTML-Seite hinzuzufügen. Dieses Audio-Tag fügt auch Audio-Steuerelemente wie Wiedergabe, Lautstärke, Pause usw. hinzu. Im Audio-Tag Das Element wird verwendet, um alternative Audiodateien auszuwählen, die der Browser auswählt. Der Browser wählt immer das erste erkannte Format. Wir können auch Text zwischen Tag, aber es führt keine Audiofunktion aus; es fungiert lediglich als einfacher Text.

Browser und zulässige Formate:

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
Browser

Formate

 

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

OGG

Edge/IE

    JA
NEIN NEIN
  • Chrom JA
  • JA JA
  • Firefox JA
  • JA JA
  • Safari JA

    JA

    NEIN

    Oper

    JA

    JA
    <!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>
    JA

    Wie funktioniert das Audio-Tag in HTML? HTML-Audio funktioniert basierend auf der Art der Audiodatei, die wir angegeben haben, und den darin verwendeten Attributen.

    HTML-Audio-Tag

    Audioformate und Medientyp:

    Dateiformat

    Medientyp
    <!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

    Audio/mpeg OGG

    HTML-Audio-Tagaudio/ogg

    WAV

    Audio/WAV

    Attribute
    <!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>
    Es handelt sich um unterschiedliche Attribute innerhalb des Audio-Tags. Dabei hat jedes Attribut seine eigene auszuführende Funktionalität. Zulässige Attribute in

    Das obige ist der detaillierte Inhalt vonHTML-Audio-Tag. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

  • Stellungnahme:
    Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
    Vorheriger Artikel:Alt-Tag in HTMLNächster Artikel:Alt-Tag in HTML