This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes how do i make a javascript slideshow using an array with imags and videos? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how do i make a javascript slideshow using an array with imags and videos?" Watch "how do i make a javascript slideshow using an array with imags and videos?" New topic
Author

how do i make a javascript slideshow using an array with imags and videos?

zsac vava
Greenhorn

Joined: Nov 30, 2012
Posts: 1
im not sure how to make my slideshow work i have a next button and previous button and it switch fine just once it goes to the videos then nothing comes up is here my html and javascript not sure on how to fix this

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>javascript homework 2</title>



<link href="css/styles.css" rel="stylesheet" type="text/css">
</head>

<body>
<div id="mainImg">
<h2 id="caption">movie1</h2>
<video id="myVideo" width="540">
<source src="video/movie1.mp4" type="video/mp4"/>
<source src="video/movie1.webm" type="video/webm"/>
<source src="video/movie1.ogv" type="video/ogg"/>
</video>



</div>
<div id="controls">
<div id="playToggle" class="player-button">Play</div>
</div>

<div id="links">

</div>

</body>
<script src="js/js.js"></script>
</html>

var currentImage = 0;



var count = 0;
var videos = new Array("movie1", "movie2", "movie3","Dk1", "Dk2", "Dk3");


var captions = new Array("movie1", "movie2", "movie3", "Dark Knight 1", "Dark Knight 2", "Dark Knight 3");


var video = document.createElement("video");
var playPauseButton = document.getElementById('playToggle');


function switchVideo() {
video.setAttribute('src',videoPaths[CurrentVideos]);
video.onload = function() {
currentVideo++;
if (currentVideo >= videoPaths.length) {
currentImage = 0;
}

}
}



function changeVideo(movie)
{
var thisVideo = "video/"+videos[movie]+".mp4";
document.getElementById("myVideo").src = thisVideo;
document.getElementById("caption").innerHTML = captions[movie];
count = movie;
}

function nextPhoto()
{
count++;

if(count==videos.length)
{
count = 0;
}

var thisVideo = "video/"+videos[count]+".mp4";
document.getElementById("myVideo").src = thisVideo;
document.getElementById("caption").innerHTML = captions[count];
}

function prePhoto()
{

count--;

if(count < 0)
{
count = videos.length-1;
}

var thisVideo = "video/"+videos[count]+".mp4";
document.getElementById("myVideo").src = thisVideo;
document.getElementById("caption").innerHTML = captions[count];
}

playPauseButton.onclick = function() {
if (myVideo.paused) {
myVideo.play();
this.innerHTML = "Pause";
} else {
myVideo.pause();
this.innerHTML = "Play";

}

};
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how do i make a javascript slideshow using an array with imags and videos?
 
Similar Threads
document.forms[0].submit(); throws Invalid Argument in IE
can't access iframe variable but can call iframe method
Doubt in HFSJ..pg 511 creating simple tag with attribute
MultiDimenaional Array sort
floating image in firefox ? still in trouble ^_^