Използвам html етикет за вграждане, за да стартирам видеоклипа си. Но имам проблем да получа събитието му, искам да извикам функция, когато се задейства събитие за възпроизвеждане или пауза. Също така искам видеото да се възпроизвежда, когато щракна върху бутона за възпроизвеждане.
Трябва ми помощта ти:
Моят код е по-долу -
<!DOCTYPE html>
<html>
<head></head>
<body>
<div class="modal-box">
<div class="modal-box-content">
<embed id="video1" src="http://player.vimeo.com/video/76979871" width="600" height="600" frameborder="0"></embed>
</div>
</div>
<button id="playButton" style="width: 80px" >Play</button>
<div >Elapsed Time: <span id="timeDisplay"></span></div>
<!-- Button width set so overall size doesn't change when we toggle the label -->
<script>
var oVideo = document.getElementById("video1"); //video element
var button = document.getElementById("playButton");
var display = document.getElementById("timeDisplay");
// Capture time changes and display current position
oVideo.addEventListener("timeupdate", function () {
display.innerText = oVideo.currentTime.toFixed(2) ;
}, false);
button.addEventListener("click", function () {
// toggle between play and pause based on the paused property
if (oVideo.paused) {
var oInput = document.getElementById('videoFile'); //text box
if (oInput.value) {
// only load a video file when the text field changes
if (oInput.value != oVideo.src) {
oVideo.src = oInput.value;
oVideo.load();
}
oVideo.playVideo();
}
} else {
oVideo.pauseVideo();
}
}, false);
// Capture the play event and set the button to say pause
oVideo.addEventListener("onplay", function () {
button.innerHTML = "Pause";
}, false);
// Capture the pause event and set the button to say play
oVideo.addEventListener("onpause", function () {
button.innerHTML = "Play";
}, false);
</script>
</body>
</html>