Webページにaudiojs を埋め込みました。
audiojsソース元は、http://kolber.github.io/audiojs/ になります。
仮のボタンの画像ファイル、button.jpgを使ってボタンを押すと、
「再生」、もう一度押すと「停止」する仕組みを作りたいです。
一つのボタンで、「再生」と「停止」ができる仕組みです。
<script src="./audiojs/audio.min.js"></script> <script> audiojs.events.ready(function() { audiojs.createAll(); }); </script> <img src="images/button.jpg" alt="Play Music" > <audio src="audio/1. .mp3" preload="auto"> <img src="images/button.jpg" class="audio-control" id="play" alt="PlayMusic" > </body>
下記がCSSで再生ボタン箇所に画像のURLを入れてみましたが、うまく機能しません。
.audiojs audio { } /* プレイヤー(再生バー) */ .audiojs { width: 80px; height: 28px; background: none; overflow: hidden; font-family: monospace; font-size: 12px; -webkit-box-shadow: none; -moz-box-shadow: none; -o-box-shadow: none; box-shadow: none; } /* 再生・停止ボタン */ .audiojs .play-pause { width: 20px; height: 20px; padding: 0; margin: 0; float: left; overflow: hidden; image: url("images/button.jpg"); border: 1px solid #3A3A3A; border-radius: 14px; } /* 再生・停止ボタンなどの p 要素 */ .audiojs p { display: none; width: 26px; height: 26px; margin: 0px; cursor: pointer; } .audiojs .play { display: block; } /* 再生ボタン */ .audiojs .play { background: url("images/button.jpg") center center no-repeat; margin-left: 1.45px; } /* 読み込み中ボタン */ .audiojs .loading { /*background: url("$1") center center no-repeat;*/ display: none; } /* エラーボタン */ .audiojs .error { /*background: url("$1") center center no-repeat;*/ display: none; } /* 停止ボタン */ .audiojs .pause { background: url("images/button.jpg") center center no-repeat; ←pauseボタン } .playing .play, .playing .loading, .playing .error { display: none; } .playing .pause { display: block; } .loading .play, .loading .pause, .loading .error { display: none; } .loading .loading { display: block; } .error .time, .error .play, .error .pause, .error .scrubber, .error .loading { display: none; } .error .error { display: block; } .error .play-pause p { cursor: auto; } .error .error-message { display: block; }
なお上記のコードに関しては、こちらより参考にさせていただきました。
ヒントをください。よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー