Can't get looping to work w/latest VLC and Firefox

All you've ever wanted to know about the ActiveX, Mozilla plugins, the web interface and various PHP extensions
Tim Quinlan
New Cone
New Cone
Posts: 4
Joined: 19 Jul 2006 15:38
Location: Boston, MA

Can't get looping to work w/latest VLC and Firefox

Postby Tim Quinlan » 19 Jul 2006 16:00

Hi,

I work for the Museum of Science in Boston and have been trying to use VLC to display a 48 hour USA lightning video in an exhibit. The video usually is about 10 seconds long. What I want to do is loop it for 1/2 hour and update it every half hour with the latest video (same name). This runs 10-12 hours a day. The code shown below is what I am using. It sould loop, but it doesn't. I am using a recursive routine to repeat the video, but this eventually ends up stopping in from 3-15 minutes.

Code: Select all

<html> <head><title>MUSEUM OF SCIENCE WEATHERWISE LIGHTNING DISPLAY</title> <script language="JavaScript"> function recursivePlayer() // used because loop fails in VLC { var videoLength = document.video1.get_length(); videoLength = (Math.abs(videoLength/2)+1)*1000; document.video1.play(); setTimeout("checkTime();recursivePlayer()",videoLength); } function checkTime() // Update video every half hour { var today = new Date(); var Minutes = today.getMinutes(); if (Minutes == 33 || Minutes == 3) { getLatestVideo(); } } function getLatestVideo() { document.video1.clear_playlist(); // clear_playlist seems to need some time before loading a new file setTimeout("document.video1.add_item('http://xxx/USAlightning.avi');",2000); // document.video1.loop=1; // tried this with true and yes also. Doesn't cause an error, but doean't loop either setTimeout("recursivePlayer()",3000); } </script> </head> <body bgcolor='black' onLoad="getLatestVideo()"> <embed type="application/x-vlc-plugin" name="video1" autoplay="no" loop="yes" width="600" height="450" fullscreen='no' /> </OBJECT> </body> </html>
BTW, when I look for the length of the video, I get a -20 instead of the expected ~10. Not sure if I am doing something wrong, but thats why the extra math on it.

Timely responses would be greatly appreciated and yes, I've tried nightly builds too, but went back to 0.8.5.

Thanks in advance for all help.

Tim

alec_robertson

Postby alec_robertson » 28 Jul 2006 21:21

You get the -20 when the video has stopped... and you can use this as a flag to trigger your looping. Check out the status function in this script: web.mit.edu/alecr/www/cwf/play.js

Tim Quinlan
New Cone
New Cone
Posts: 4
Joined: 19 Jul 2006 15:38
Location: Boston, MA

Postby Tim Quinlan » 01 Aug 2006 16:47

Hi,

Alec, Thanks for your explaination and advice.

I've worked up a better way to loop by checking every second to see if the video is still playing (document.vlc.isplaying()). If it is finished, I check to see if it is time to get the latest video. It is important to stop the recursive timeout. If it is not time to update the video, just play it again. In getting the latest video, it is important to stop the player. Failing to do this, as in stopping the timeout, will cause the player and Firefox to crash.

Code: Select all

<html> <head><title>MUSEUM OF SCIENCE WEATHERWISE LIGHTNING DISPLAY</title> <script language="JavaScript"> function recursivePlayer() // Used because loop fails in VLC { var videoPlaying = document.vlc.isplaying(); if (videoPlaying != 'true') {clearTimeout(recursiveTimer);checkTime();setTimeout("document.vlc.play()",1000)}; var recursiveTimer = setTimeout("recursivePlayer()",1000); } function checkTime() // Update video every half hour { var today = new Date(); var Minutes = today.getMinutes(); if (Minutes == 34 || Minutes == 4) { // a new video is produced every half hour getLatestVideo(); // give it enough time to finsh } } function getLatestVideo() { document.vlc.stop(); // make sure player is stopped document.vlc.clear_playlist(); // clear_playlist seems to need some time before loading a new file setTimeout("document.vlc.add_item('http://xxx/USAlightning.avi')",2000); setTimeout("recursivePlayer()",3000); } </script> </head> <body bgcolor='black' onLoad="getLatestVideo()"> <embed type="application/x-vlc-plugin" name="vlc" autoplay="no" loop="yes" width="600" height="450" fullscreen='yes' /> </body> </html>
This method of playing a video is only being used on a Windows machine, using Firefox, and running as a non-interactive kiosk. No browser checking etc.

If I encounter any problems with this solution, I will post them

Tim

-Hawk-

Postby -Hawk- » 03 Aug 2006 19:25

I think this is what you are looking for:

Code: Select all

<div> <!-- object id="alert" type="audio/wav" DO NOT use the proper mime type. Firefox will force you to load Apple's Quicktime garbage. --> <object id="alert" type="application/x-mplayer2"><!-- Use existing windows media player --> <param name="src" value="/alert.wav" /> <param name="controls" value="hidden" /> <param name="autostart" value="~S-alert~" /> <param name="volume" value="0" /> <param name="playcount" value="1" /><!-- 0 means loop forever --> <param name="loop" value="1" /><!-- does nothing --> <param name="autorewind" value="1" /><!-- does nothing --> </object> </div>

-Hawk-

Postby -Hawk- » 03 Aug 2006 19:29

Actually that last one was for audio, this is video. The key is the param "PLAYCOUNT". Do not use "LOOP" or "AUTOREWIND".

Code: Select all

<div> <object type="application/x-mplayer2" width="160" height="120" id="movie" src="~S-cgi~?goto=movie&movie=1"> <!-- Do not use values of True or False, only 1 or 0! --> <param name="src" value="can also go here" /> <param name="showcontrols" value="0" /> <param name="showstatusbar" value="0" /> <param name="volume" value="-10000" /> <param name="playcount" value="1" /><!-- 0 means loop forever --> </object> </div>

Tim Quinlan
New Cone
New Cone
Posts: 4
Joined: 19 Jul 2006 15:38
Location: Boston, MA

Postby Tim Quinlan » 14 Aug 2006 20:32

Hi all,

This is the current solution that seems to work well, but with a caveat.

Code: Select all

<html> <head><title>MUSEUM OF SCIENCE WEATHERWISE LIGHTNING DISPLAY</title> <style type="text/css"> .larger_text{ font-family: arial, helvetica, sans serif; font-size: 30pt; font-weight: bold; color: #FFFFFF; } #message{ position: absolute; left: 25; top: 100; width: 750; height: 200; } #video{ position: absolute; left: 25; top: 30; width: 750; height: 500; } </style> <script language="JavaScript"> function recursivePlayer() // Used because loop fails in VLC { var videoPlaying = document.vlc.isplaying(); if (videoPlaying != 'true') {clearTimeout(recursiveTimer);setTimeout("document.vlc.play()",10000)}; var recursiveTimer = setTimeout("recursivePlayer()",1000); } function loadVideo() { setTimeout("showMessage('DOWNLOADING LATEST VIDEO')",4000); setTimeout("document.vlc.clear_playlist()",5000); setTimeout("document.vlc.add_item('http://xxxUSAlightning.avi')",7000); setTimeout("document.vlc.play()",150000); setTimeout("showMessage('2 DAY USA LIGHTNING LOOP ENDING '+Date());recursivePlayer()",16000); } function showMessage(msg) { x = document.getElementById('message'); x.innerHTML = ''; x.innerHTML = "<SPAN class='larger_text'><CENTER>"+msg+"</CENTER></SPAN>"; } </script> </head> <body bgcolor='black' text='white' onLoad="loadVideo()"> <DIV ID='video'> <embed type="application/x-vlc-plugin" name="vlc" autoplay="no" loop="yes" width="750" height="500" fullscreen='no' /> </DIV> <DIV ID='message'></DIV> </body> </html>
The caveat is this: Firefox seems to crash after running this for more than an hour. The solution I am using, is to quit firefox and restart it every half hour, shortly after a new video is produced. Thus, I don't have to stop vlc, clear the playlist, fetch the latest video and start playing again.

I use cron to run a batch file that kills the Firefox process (process.exe) then restarts it with another script (created with autoit3) that starts it, then sends an {F11} after it is running, to have it run full screen. I may look into adding the batchfile job into the one created with autoit3.

As I said before, this is running as a non-interactive kiosk, running Windows2000, displaying USA lightning strikes over the past 2 days.

I know that this is quite a hack, but it is working. I now have to move on to another vlc based video application. This one displays live video from a roof camera for 30 seconds, then shows a 3 hour time lapse video taken with this camera at an image per minute. The way we are doing it now shows the Windows desktop between each view. I want to try to do this one using HTML too.

Thanks for all the suggestions made so far.


Return to “Web and scripting”

Who is online

Users browsing this forum: No registered users and 38 guests