Go Back   CodingForums.com > :: Client side development > JavaScript programming

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 02-23-2013, 10:11 PM   PM User | #1
tsgortr
New to the CF scene

 
Join Date: Feb 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
tsgortr is an unknown quantity at this point
Onclick events firing in sequence, instead of at button press...

Hello! As the title says, I have a piece of javascript using onclicks that I'm trying to use with the embedded VLC player to switch webcam feeds by pressing the appropriate button. The code is below (Ip's replaced with #'s). The behavior I want is "press a button -> appropriate webcam feed displayed." What I get (in Firefox 17 anyway) is "press webcam 1 button -> webcam 1 feed displayed -> (after 30 or so seconds) webcam2 feed displayed -> (after another 30 seconds) webcam 3 feed displayed." At webcam 3 the looping seems to stop, thus pressing the button for feed 3 stays on feed three. It seems like the javascript is just executing in sequence, and being very new to this I'm not sure if that should even be happening, let alone how to fix it. If someone could look at the below code and give me a suggestion how to fix my little webpage I'd be grateful. Thanks!

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Draft//EN">
<HTML>
<HEAD>
<TITLE></TITLE>



</HEAD>
<BODY>



<embed  type="application/x-vlc-plugin"
	autoplay="no"
	loop="no"
	id="vlc"
	pluginspage="http://www.videolan.org" 
	version="VideoLAN.VLCPlugin.2"
	width="320" 
	height="240"
	> 
</embed>

<br />
<button href="javascript:;" onclick="Cam1()">Webcam 1</button>
<button href="javascript:;" onclick="Cam2()">Webcam 2</button>
<button href="javascript:;" onclick="Cam3()">Webcam 3</button>

<script language="javascript">

var options = new Array ("aspect-ratio=4:3", "--repeat");
var Video1 = vlc.playlist.add("rtsp://###.###.##.###:8081/", "MRL1", options);
var Video2 = vlc.playlist.add("rtsp://###.###.##.###:8082/", "MRL2", options);
var Video3 = vlc.playlist.add("rtsp://###.###.##.###:8084/", "MRL3", options);

function Cam1() {
vlc.playlist.stop();
vlc.playlist.playItem(Video1);
}

function Cam2() {
vlc.playlist.stop();
vlc.playlist.playItem(Video2);
}

function Cam3() {
vlc.playlist.stop();
vlc.playlist.playItem(Video3);
}

</script>

</BODY>
</HTML>
tsgortr is offline   Reply With Quote
Old 02-24-2013, 09:36 AM   PM User | #2
Celtboy
Regular Coder

 
Join Date: May 2002
Location: Virginia, USA
Posts: 620
Thanks: 0
Thanked 6 Times in 6 Posts
Celtboy is an unknown quantity at this point
I haven't played with it, but what if you added
Code:
vlc.playlist.stop();
after each of your playItem()* lines?
Celtboy is offline   Reply With Quote
Reply

Bookmarks

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 11:54 AM.


Advertisement
Log in to turn off these ads.