I try to work with HTML5 tag and create my own palyer.
My html:
<video id="video">
<source src="video/v.mp4" />
<source src="video/v.ogg" />
<source src="video/v.webm" />
</video>
<br />
<button id="part1Button">
1
</button>
<button id="part2Button">
2
</button>
<button id="part3Button">
3
</button>
<button id="playButton">play</button>
<button id="pauseButton">pause</button>
My JavaScript:
<script type="text/javascript">
window.onload = function () {
var video = document.getElementById("video");
var p = v.duration / 3;
document.getElementById("part1Button").onclick = function () {
video.currentTime = 0;
};
document.getElementById("part2Button").onclick = function () {
video.currentTime = p;
};
document.getElementById("part3Button").onclick = function () {
video.currentTime = p * 2;
};
document.getElementById("playButton").onclick = function () {
video.play();
};
document.getElementById("pauseButton").onclick = function () {
video.pause();
};
}
</script>
All three buttons: 1,2,3 do not work in Google Chrome. I will have the next error when I click on them : "Uncaught TypeError: Failed to set the 'currentTime' property on 'HTMLMediaElement': The provided double value is non-finite".
When I replace video.currentTime = p * 2 on video.currentTime = (video.duration / 3) * 2 everything works fine.
Can somebody explan me why is this happening?
Many thanks.