HTMLページのオーディオ要素の動作を処理する必要があります。音声は、ユーザーがページに到着すると開始します。私は、同じセッション中に再び彼がページに達すると、もう一度演奏したくないです。私はそのコードを試みたが、うまくいきません。あなたはそれについていくつかの示唆を持っていますか?どうもありがとうございましたHtml 5オーディオローカルストレージ
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<audio controls autoplay class="hidden-xs" style=" position:fixed; right:0; bottom:0; z-index:99999999999">
<source src="music_bbms.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<script>
$(document).ready(function() {
if (!localStorage.getItem('played') {
$('.music').attr('autoplay', false);
localStorage.setItem('played', true);
}
});
</script>
'オーディオを開始するユーザーは、これを実行しないでくださいpage'に到着したとき。もはや1996年ではない。 –
セッションが存在する場合、あなたはプレーヤーを 'remove()'することができます –
あなたの 'if'条件に') 'がありません。 –