Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-12-2012, 02:14 PM   PM User | #1
mtsgill
New to the CF scene

 
Join Date: Dec 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
mtsgill is an unknown quantity at this point
Unhappy Help with my JavaScript Code [Functions]

Hi friends.

I have been reading some fantastic stuff around and must admit that you all are doing a wonderful job by helping each other.

I have a slight problem here. I have been trying to work on a little project called "Interactive Narrative Media".

My aim is to create a html page with a Video1 being auto played to start with. Before the video finishes, It shall display two button choices with links to further video and those video clips shall display further buttons to make user interaction possible.

So far, I have been able to define buttons 1 and 2 and their display time using setTimeout and visibility options. I have also linked first two buttons with the video 2 and video3.

MY QUESTION IS: How can I make button 3 and 4 to appear on video 3 and video 4 (depends on whichever user clicks at?) Also, how and where shall I define my buttons 3 and 4 as well as video 4 and 5? Your help would be HIGHLY appreciated!

Here is my code:

<div id="left">
<!--Two buttons are defined here-->
<button onclick="turnLeft()" id="button1" style="position: absolute; left: 55px; top: 473px; height: 33px;">Turn Left</button>
<button onclick="turnRight()" id="button2" style="position: absolute; left: 465px; top: 473px; height: 33px;">Turn Right</button>
<br>
<!--First video on page load is defined here and set to autoplay with customised dimensions-->
<video id="video1" controls="controls" autoplay="autoplay" width="591" height="440">
<source id="mp4_src" src="video1.m4v" type="video/mp4">
</video>
<script>
// 14 seconds delay for left button to appear on video
function showLeft() {
document.getElementById("button1").style.visibility = "visible";
}
setTimeout("showLeft()", 14000);
// 14 seconds delay for right button to appear on video
function showRight() {
document.getElementById("button2").style.visibility = "visible";
}
setTimeout("showRight ()", 14000);
//link to left choice video once left button is pressed and button gets cleared from the video frame at the same time
function turnLeft()
{
document.getElementById("button1").style.visibility="hidden";
document.getElementById("button2").style.visibility="hidden";
document.getElementById("mp4_src").src="video2.m4v";
document.getElementById("video1").load();
}
//link to right choice video once right button is pressed and button gets cleared from the video frame at the same time
function turnRight()
{
document.getElementById("button2").style.visibility="hidden";
document.getElementById("button1").style.visibility="hidden";
document.getElementById("mp4_src").src="video3.m4v";
document.getElementById("video1").load();
}
</script>
<br>
</div>
mtsgill is offline   Reply With Quote
Reply

Bookmarks

Tags
dom, functions, javascript, video

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:15 AM.


Advertisement
Log in to turn off these ads.