JavaScript를 사용하여 루프 태그 (ff)를 지원하지 않는 브라우저에서 html5 비디오를 반복 할 수있게하려고합니다. 비디오 재생의 끝 부분에 액세스하고 재생을 0으로 되 돌리는 타당성을 아는 사람이 있습니까?컨트롤 html5 비디오 플레이어 루프 (JavaScript 포함)
5
A
답변
15
loop
속성이 지원되는지 감지하고 true
으로 설정할 수 있습니다. 당신은 단순히 ended
미디어 이벤트를 바인딩 할 수 있습니다, 그것을 시작을 지원하지 않는 브라우저의 경우
:
var myVideo = document.getElementById('videoId');
if (typeof myVideo.loop == 'boolean') { // loop supported
myVideo.loop = true;
} else { // loop property not supported
myVideo.addEventListener('ended', function() {
this.currentTime = 0;
this.play();
}, false);
}
//...
myVideo.play();
0
<div>Iteration: <span id="iteration"></span></div>
<video id="video-background" autoplay="" muted="" controls>
<source src="https://res.sdfdsf.mp4" type="video/mp4">
</video>
var iterations = 1;
document.getElementById('iteration').innerText = iterations;
var myVideo = document.getElementById('video-background');
myVideo.addEventListener('ended', function() {
alert('end');
if (iterations < 2) {
this.currentTime = 0;
this.play();
iterations ++;
document.getElementById('iteration').innerText = iterations;
}
}, false);
// Please note that loop attribute should not be there in video element in order for the 'ended' event to work in ie and firefox
1
할 수 있습니다 단순히 루프를 중지하는 loop="false"
를 통해 비디오 또는 해제 자동 비디오 반복 재생.
<iframe style="position: absolute; top: 0; left: 0;"
src="http://video/name.mp4" width="100%" height="100%" frameborder="0" webkitallowfullscreen loop="true" controls="false" mozallowfullscreen allowfullscreen></iframe>
이 loop="true"
은 비디오 플레이어 루프를 활성화합니다.
관련 문제
- 1. html5 mp4 비디오 플레이어
- 2. jQuery 및/또는 HTML5 비디오 플레이어 (고급 기능 포함)
- 3. 많은 플랫폼을위한 비디오 플레이어
- 4. iPhone 비디오 플레이어 - 플레이어 방향 변경 (재생 목록 포함)
- 5. HTML5 비디오 - 프로그래밍 방식으로 컨트롤 표시/숨기기
- 6. HTML5 : iPad의 비디오 - 맞춤 확대/축소 컨트롤
- 7. HTML5 비디오 (Chrome/PC)
- 8. 가장 간단한 컨트롤 (재생 및 일시 중지 만)이있는 html5 비디오 플레이어
- 9. Canvas vs Fox 비디오 플레이어 용 이미지
- 10. Silverlight 3 비디오 플레이어
- 11. 자바 비디오 플레이어
- 12. 안드로이드 비디오 플레이어
- 13. 플래시 비디오 플레이어 자막
- 14. PHP의 축소판 비디오 플레이어
- 15. WordPress의 비디오 플레이어 플러그인
- 16. YouTube 플레이어 플러그인 비디오
- 17. 스트리밍 비디오 플레이어
- 18. Android의 비디오 플레이어?
- 19. Javascript 오디오/비디오 요소 컨트롤 볼륨을 프로그래밍 방식으로?
- 20. 스트리밍 m4v 파일을 지원하는 플래시 비디오 플레이어
- 21. HTML5 비디오 검증 오류
- 22. HTML5 m3u/asx 스트림 플레이어
- 23. 플래시 비디오 플레이어 VS HTML 5 비디오
- 24. Facebook 비디오 미리보기 및 비디오 플레이어
- 25. 서비스가있는 미디어 플레이어 컨트롤
- 26. Silverlight 오디오 플레이어 컨트롤
- 27. UIWebView HTML5 비디오 오리엔테이션
- 28. HTML5 비디오 문제
- 29. 인코딩 비디오 html5 재생
- 30. iPhone에서 HTML5 비디오