在HTML
<video id="player" width="320" height="240" src="video1.ogv" type="video/ogg" controls="controls">
</video>
和Java腳本:
<script language="javascript">
var video1 = "video1.ogv";
var video2 = "video2.ogv";
var player = document.getElementById("player");
player.setAttribute("ontimeupdate", "update();");
var time = 0.0;
var toUpdate = false;
function changeVideo() {
time = player.currentTime;
if (player.src.match(video1+"$") == video1)
player.src = video2;
else
player.src = video1;
player.load();
toUpdate = true;
player.play();
}
function update() {
if (flag) {
player.currentTime = time;
toUpdate = false;
}
}
</script>
嘗試ŧ o檢查這個http://stackoverflow.com/questions/5981427/start-html5-video-at-a-particular-position-when-loading – gregjer
我怎樣才能使視頻開始自動播放 – Chinthu
添加自動播放屬性後控制內您的視頻標籤 另請參閱https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_HTML5_audio_and_video – gregjer