简体   繁体   中英

RTSP streaming with VLC: changeable rtsp IP by user

So simply I have the code below for streaming rtsp with VLC on webpage. Is it too complicated to have script to change the rtsp address by user (lets say right click on video and pick another rtsp address from drop-down list) ?

embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org" version="VideoLAN.VLCPlugin.2" width="100%" height="100%" id="vlc" loop="yes" autoplay="yes" target="rtsp://192.168.1.225">

Thanks for your help...

What you are looking for might not be easily possible. However, you can very well change the embed content using button clicks. I am attaching a working solution below

code for embed-

<embed id="camFeed" type="application/x-vlc-plugin" pluginspage="http://www.videolan.org" autoplay="yes" loop="no" bgcolor="#fff" width="752" height="424" src="" />

code for button-

 <button type="button" onclick="newFeed()">Click Me!</button>

function for changing the content-

<script type="text/javascript">
function newFeed()
{
     document.getElementById("camFeed").src = "rtsp://xxx.xxx.xxx.xxx:554";
}
</script>

Note: If you want to display feed from a list of cameras, you will have to look into importing php arrays into js using json_encode()

You must to change it using js, I use this:

HTML:

<embed type="application/x-vlc-plugin"
    pluginspage = "http://www.videolan.org"
    id = "vlc"
    width = "100"  
    height ="100"
    autoplay = "true"
    src = "HERE TYPE YOUR FIRST IP"
/>

JS (example with Jquery):

var vlc = $("#vlc")[0];
var newSrc = "HERE TYPE YOUR SECOND IP";
vlc.playlist.stop();
vlc.playlist.items.clear();
var item = vlc.playlist.add(newSrc);
vlc.playlist.playItem(0);

You can get more info here: https://wiki.videolan.org/Documentation:WebPlugin

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM