CMS Made Simple(Smarty、jQuery)と呼ばれるCMSで構築されたWebサイト(html5)で、バックグラウンドミュージックにhtml5オーディオタグを使用しています。
<div id="audio">
<div style="width:150px;height:15px;margin:0;padding:0;">
<div style="width:57px;float:left;">
<a href="javascript:;" id="play" onclick="document.getElementById('andytimm').play()" title="Play"><img src="images/audio_play.png" width="" height="" alt="Play"></a>
</div>
<div style="width:50px;float:left;">
<a href="javascript:;" id="pause" onclick="document.getElementById('andytimm').pause()" title="Pause"><img src="images/audio_pause.png" width="" height="" alt="Pause"></a>
</div>
<div style="width:36px;float:left;">
<a href="javascript:;" id="stop" onclick="document.getElementById('andytimm').pause(); document.getElementById('andytimm').currentTime = 0;" title="Stop"><img src="images/audio_stop.png" width="" height="" alt="Stop"></a>
</div>
<div style="clear:both;"></div>
</div>
<audio id="andytimm">
<source src="mysong.mp3">
<source src="mysong.ogg">
</audio>
<!--[if lt IE 9]>
<object id="andytimmObj" type="audio/x-mpeg" data="mysong.mp3" autoplay="false" height="45">
<param name="src" value="mysong.mp3">
<param name="controller" value="false">
<param name="autoplay" value="false">
<param name="autostart" value="0">
</object>
<script>
document.getElementById('play').onclick = function() { document.getElementById('andytimmObj').play() };
document.getElementById('pause').onclick = function() { document.getElementById('andytimmObj').pause() };
document.getElementById('stop').onclick = function() { document.getElementById('andytimmObj').stop() };
</script>
<![endif]-->
</div>
サウンドは問題なく動作します。
それほど良くないのは、サイトを変更すると音楽が停止することです。おそらく「サービス」から「連絡先」またはその他のサイトに変更します。サイトが変わっても音楽を再生し続ける方法はありますか? 私はプログラマーではないので、解決策を見つけるのは難しいです。