VLC streaming 'changing src onlick' javascript code can hear sound/can't see video (Answered)-Collection of common programming errors

Hi this post actually has two questions.

I’m trying to add a vlc player (version 1.1.8, live stream, internet explorer) to my webpag and give the user the ability to change channel by clicking one of the buttons.

 
  





The code above works fine, I can hear and see the video but I don’t know how to change the Src value upon click (the udp/channel). I tried to use the code:

document.getElementById('vlcplayer').src = 'udp://@239.0.10.105:1234' 

but that doesn’t work as .src seems to be undefined.

Q1. Is there a way to change the src of the object? Could I get an example please?

I couldn’t find a way so I resorted to create the object in javascript with the src as variable whenever a channel button is clicked:

uri = 'udp://@239.0.10.115:1234';
VLCPlayerObject = '  '; 
document.getElementById('videoDisplayDivID').innerHTML=VLCPlayerObject;

The problem with this code however is that I can’t see the video but I can hear it and I can hear the channel changing.

Q2. Is this some software problem or is my coding wrong? How do I fix it?

UPDATE

I attempted to make the following changes in a new test version

in the object I added an id:

 

was changed to

  

and then in the javascript code:

var temp = document.getElementById("videoSrc").getAttribute("value");
alert("old udp: " + temp);

var sourceParameter= document.getElementById("videoSrc");
sourceParameter.setAttribute("value", "udp://@239.0.10.115:1234");

var temp2 = document.getElementById("videoSrc").getAttribute("value");
alert("new udp: " + temp2);

This code does display the udp and it shows that the udp does change after the function is run. HOWEVER although the udp changes the video doesn’t actually switch to that channel for some reason. (I’ve checked that the channels are different)

Q3. How do I get the video to update as well?

ANSWERED

Added an item to the playlist (the original src value gets set as playlist item 0 btw)

var vlc = document.getElementById("vlcplayer");
vlc.playlist.add("udp://@239.0.10.115:1234");
vlc.playlist.playItem(1);

Now I just have to properly code it to work for every channel.

Thanks millimoose.

Originally posted 2013-11-19 13:18:52.