Menu
Can scripting be used to access the time mark during play so that images can be rolled next to it to make a slideshow?
[code=html]
<video id="vidElem" width="640" height="480">
<source src="movie.webm" type="video/webm" />
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
[/code]
<i>
</i>var $video = document.getElementById('vidElem');
$video.addEventListener("canplay", _InitSync, false);
function _InitSync() {
$video.addEventListener("timeupdate", _SyncSlides, false);
}
function _SyncSlides() {
$curTime = $video.currentTime;
}
Let me know if this resolves your issue or not.[/QUOTE]
[code=html]<head>
<!--
.
.
-->
<script type="text/javascript">
var slidesBlock, // DOM element containing slideshow images
timeMarks = [ 50, 70, 80, 170, 200, 250 ],
timeMarkIndex = 0,
currentTimeMark = timeMarks[timeMarkIndex],
preloadedImages = [];
function initialize() {
var i, img, index,
myVid = document.getElementById("ballet-vid"),
slidesBlock = document.getElementById("slideshow");
if (typeof myVid.addEventListener == "function")
myVid.addEventListener("canplay", function () {
initSync(myVid, slidesBlock); }, false);
else if (typeof myVid.attachEvent == "function")
myVid.attachEvent("oncanplay", function () {
initSync(myVid, slidesBlock); } );
// preload images
for (i = 0; i < timeMarks.length; i++) {
img = new Image();
img.alt = "still #" + (i + 1) + " of My Video";
index = "0";
if (i < 9)
index += i + 1;
else
index = i + 1
img.src = "StillsOfMyVideo-" + index + ".png";
img.style.width = "500px";
preloadedImages.push(img);
}
}
function initSync(vidClip, slideShowBlock) {
if (typeof vidClip.addEventListener == "function")
vidClip.addEventListener("timeupdate", function () {
syncSlides(vidClip, slideShowBlock); }, false);
else if (typeof vidClip.attachEvent == "function")
vidClip.attachEvent("ontimeupdate", function () {
syncSlides(vidClip, slideShowBlock); } );
}
function syncSlides(vidClip, slideShowBlock) {
if (vidClip.currentTime > currentTimeMark) {
slideShowBlock.replaceChild(preloadedImages[timeMarkIndex++], slideShowBlock.firstChild);
currentTimeMark = timeMarks[timeMarkIndex];
}
}
</script>
</head>
<body onload="initialize();">
<p style-"margin:0;">
<video controls preload id="ballet-vid" poster="poster.png"
style="float:left;margin:0 1.5em 0.5em -10%;border:1px solid lime;">
style="border:1px solid lime;padding:0;margin:0;">
<source src="myvid.mpg" type="video/mpeg">
<source src="myvid.mp4" type="video/mp4">
<source src="myvid.webm" type="video/webm">
<object data="myvid.mpg" type="video/mpeg" width="750" height="600">
<embed src="myvid.mpg" type="video/mpeg" width="750" height="600">
</object>
</video>
<p id="slideshow"><img src="poster.png" alt="initial image of slideshow">
</body>
[/code]
0.1.9 — BETA 5.24