【HTML5課題17】音声再生
○音声を再生させなさい。
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <title></title> <link rel="stylesheet" href=""> <script src=""></script> <!--[if lte IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!--[if lte IE 9]> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <![endif]--> <style> article, aside, dialog, figure, footer, header, hgroup, menu, nav, section { display: block; } </style> </head> <body> <h1>サンプル音声を再生</h1> <audio src="image/sample.mp3" controls> <p>ブラウザ上で再生できない方は<a href="image/sample.mp3">音声のダウンロード</a>をどうぞ。</p> </audio> </body> </html>
○audio要素:プラグインなしで、音声を再生
○src属性:音声ファイルのアドレスを指定
○controls属性:音声の再生や停止ボタンなどのユーザーインターフェイスを表示
○autoplay属性:音声が再生可能になると自動で再生
○loop属性:再生終了後、最初に戻って再生を続ける