html
1<video id="player" preload> 2 <source src="<?php bloginfo('template_url'); ?>/video/haikeiPV.mp4" type="video/mp4" autoplay> 3 <source src="<?php bloginfo('template_url'); ?>/video/haikeiPV.ogv" type="video/ogg" autoplay> 4 <source src="<?php bloginfo('template_url'); ?>/video/haikeiPV.webm" type="video/webm" autoplay> 5 </video>
Javascript
1//動画の自動再生 2 jQuery(function(){ 3 var player = jQuery('#player').get(0); //videoタグの要素を取得 4 5 player.play(); //動画の再生 6}); 7 8 //動画が終わったらvideoタグを削除する 9 jQuery(function(){ 10 var player = jQuery('#player').get(0); //videoタグの要素を取得 11 12 player.play(); //動画の再生 13 14 //動画が終了したことを検出して発火する処理 15 player.addEventListener('ended',function() { 16 jQuery('#player').remove(); //videoタグをDOM的に削除 17 }); 18 });
HTMLをwordpress化したら動画が自動再生できなくなった。
本来なら、ホームページを読み込んだ際に動画が自動再生され、終了したら自動的に消える仕組みなのですが、ホームページを読み込んだ際に動画が自動再生されないので困っているので、エラーメッセージが分かる方がいましたら、ご教授願いたいです。よろしくお願いします。
エラーメッセージ
JQMIGRATE: Migrate is installed, version 1.4.1
Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.
Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.
回答1件
あなたの回答
tips
プレビュー