Etc / / 2020. 11. 19. 12:10

동영상 자동 재생

728x90
<iframe id="vimeo" src="https://player.vimeo.com/video/73445911?autoplay=0&amp;loop=1&amp;autopause=0&amp;muted=1" allow="autostart" data-ready="true" frameborder="0"></iframe>
const id = document.querySelector("#vimeo");
const player = new Vimeo.Player(id);
player.play();

가장 중요한 게 muted=1입니다.

PC에서 쓰는 브라우저에서는 mute만 추가하면 어지간해서는 자동으로 재생이 가능합니다.

혹시나 안 되는 브라우저의 경우는 해당 브라우저 정책을 확인해 보실 필요가 있겠네요.

아래는 크롬 브라우저의 동영상 자동 재생에 관련된 정책인데 읽어 보시면 됩니다.

developers.google.com/web/updates/2017/09/autoplay-policy-changes?hl=ko

 

Autoplay Policy Changes  |  Web  |  Google Developers

Learn best practices for good user experiences with the new autoplay policies in Chrome, coming April 2018.

developers.google.com

 

반응형

'Etc' 카테고리의 다른 글

[VS Code]Extensions  (0) 2020.12.16
국가별 영문명  (0) 2020.11.23
#2002 - No such file or directory  (0) 2020.11.17
Facebook 공유하기 관련 메타 태그  (0) 2020.10.19
highlight.js tab size 조절하기  (0) 2020.06.24