Как установить звуковую петлю в amp-audio Google AMP?
Опубликовано: 12 Апреля, 2022
С момента выпуска HTML5 аудио можно добавлять на веб-страницы с помощью тега «audio». Раньше аудио можно было воспроизводить только на веб-страницах с помощью веб-плагинов, таких как Flash. Тег «audio» - это встроенный элемент, который используется для встраивания звуковых файлов на веб-страницу. Это очень полезный тег, если вы хотите добавить на свою веб-страницу аудио, например песни, интервью и т. Д. Чтобы встраивать аудио в страницы AMP, вы должны использовать тег amp-audio.
Setup: To use the amp-audio, you have to import the amp-audio component into the head of the webpage.
HTML
< script async custom-element = "amp-audio" src = </ script > |
Чтобы звук запускался автоматически, когда аудиофайл заканчивается, мы используем атрибут loop в amp-audio.
Example:
HTML
<!doctype html> < html amp> < head > < meta charset = "utf-8" > < title >Google AMP amp-audio</ title > < script async src = </ script > <!-- Import the `amp-audio` component --> < script async custom-element = "amp-audio" </ script > < link rel = "canonical" href = < meta name = "viewport" content = "width=device-width,minimum-scale=1,initial-scale=1" > < style amp-boilerplate> body { -webkit-animation: -amp-start 8s steps(1, end) 0s 1 normal both; -moz-animation: -amp-start 8s steps(1, end) 0s 1 normal both; -ms-animation: -amp-start 8s steps(1, end) 0s 1 normal both; animation: -amp-start 8s steps(1, end) 0s 1 normal both; } @-webkit-keyframes -amp-start { from { visibility: hidden } to { visibility: visible } } @-moz-keyframes -amp-start { from { visibility: hidden } to { visibility: visible } } @-ms-keyframes -amp-start { from { visibility: hidden } to { visibility: visible } } @-o-keyframes -amp-start { from { visibility: hidden } to { visibility: visible } } @keyframes -amp-start { from { visibility: hidden } to { visibility: visible } } </ style > < noscript > < style amp-boilerplate> body { -webkit-animation: none; -moz-animation: none; -ms-animation: none; animation: none } </ style > </ noscript > < style amp-custom> h1 { color: forestgreen; } </ style > </ head > < body > < center > < h1 > Geeks For Geeks </ h1 > </ center > < amp-audio width = "auto" height = "50" src = "GeeksForGeeks.mp3" controls loop> < div fallback> Your browser doesn’t support HTML5 audio... </ div > </ amp-audio > </ body > </ html > |
Выход: