Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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>

  • #2
    Regular Coder
    Join Date
    May 2002
    Location
    Virginia, USA
    Posts
    620
    Thanks
    0
    Thanked 6 Times in 6 Posts
    I haven't played with it, but what if you added
    Code:
    vlc.playlist.stop();
    after each of your playItem()* lines?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •