Detecting if stream exists?

All you've ever wanted to know about the ActiveX, Mozilla plugins, the web interface and various PHP extensions
carlosabdomingos
Blank Cone
Blank Cone
Posts: 15
Joined: 03 Sep 2008 15:56

Detecting if stream exists?

Postby carlosabdomingos » 08 Sep 2008 17:00

I have the following code in a web page:

Code: Select all

<html> <title>VLC Mozilla plugin test page</title> <body> <embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org" version="VideoLAN.VLCPlugin.2" width="640" height="480" id="vlc"> </embed> <script language="Javascript"> <!-- //var vlc = document.getElementById("vlc"); //vlc.audio.toggleMute(); function doPlayOrPause() { var vlc = getVLC("vlc"); if( vlc.playlist.isPlaying ) { vlc.playlist.togglePause(); } else if( vlc.playlist.items.count > 0 ) { // clear the message log and enable error logging vlc.log.verbosity = 1; vlc.log.messages.clear(); vlc.playlist.play(); monitor(); alert('playing!') } else { // disable log vlc.log.verbosity = -1; alert('nothing to play!'); } }; !--> </script> </body> </html>
I want to receive a message to know if the web page is receiving something from vlc, but he don't appears nothing.

What is wrong? Everyone have one ideia for make a test page?

The basic code is:

Code: Select all

<html> <title>VLC Mozilla plugin test page</title> <body> <embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org" version="VideoLAN.VLCPlugin.2" width="640" height="480" id="vlc"> </embed> <script language="Javascript"> <!-- var vlc = document.getElementById("vlc"); //vlc.audio.toggleMute(); !--> </script> </body> </html>

DWard
New Cone
New Cone
Posts: 2
Joined: 25 Nov 2008 13:56

Re: Detecting if stream exists?

Postby DWard » 25 Nov 2008 15:06

I'm not sure if you manged to solve this issue, however I had the same problem and believe I've solved it.

The documentation provided for the VLC plugin mentions the values of 'input.state' as below:
(IDLE/CLOSE=0, OPENING=1, BUFFERING=2, PLAYING=3, PAUSED=4, STOPPING=5, ERROR=6)
Great, so the 'ERROR' state will be returned when there is an error 404 (File not found).. No it isn't. So, after a little debugging, I found the plugin to be returning a status code '8' only when the video is not found.

Following this, the below code will loop every 10th of a second (this should be fine, but if it makes you nervous, increase it a little) and check the status. If the status code returns '6' (error of some kind) or '8' (the 404 status (unconfirmed)), then it will execute the code of your choice.

Place the following code above </body>

Code: Select all

<script language="javascript"> /* <![CDATA[ */ // Declare VLC ID var vlc = document.getElementById("vlcPlayer"); function checkVLC() { // If VLC has returned an error if (vlc.input.state == 6 || vlc.input.state == 8) { // Execute some code or a function alert("VLC player has returned an error (Code: " + vlc.input.state + ")"); } else { // Loop to function again setTimeout("checkVLC();", 100) } } // Run VLC script intially checkVLC(); /* ]]> */ </script>
Dan Ward - Portfolio


Return to “Web and scripting”

Who is online

Users browsing this forum: No registered users and 4 guests