Page 1 of 1

VLC Timer?

Posted: 02 Jan 2010 18:50
by CheeseKing
I have a bit of a predicament which I'm hoping one of you fine folks can help with. You see, I use VLC to play an endless loop of a certain sound file to help me get to sleep at night. Thing is, it keeps playing long after I've gotten to sleep. I'd like to set a timer if possible to make VLC shut down, or perhaps simply stop playing after a set amount of time. Say, an hour or so. Is there any way to do this?

Re: VLC Timer?

Posted: 16 Jan 2010 03:39
by CheeseKing
<------------->

Re: VLC Timer?

Posted: 22 Jan 2010 14:48
by Arite
You can use the --input-repeat commandline option.

For example, running the command:

Code: Select all

vlc.exe --input-repeat 9 C:\Temp\File.mp3 vlc://quit
Will play the file "C:\Temp\File.mp3" 10 times (i.e. repeated 9 times). After that VLC will close (what vlc://quit does).

If you wanted to shutdown you PC you could write a Batch script with a shutdown command after the VLC one. For example:

Code: Select all

"C:\Program Files\VideoLAN\VLC\vlc.exe" --input-repeat 9 C:\Temp\File.mp3 vlc://quit shutdown -s -t 0
Where "C:\Program Files\VideoLAN\VLC" is the location of VLC.

That should play the file 10 times in VLC, close VLC and then shutdown your computer. You can just write something like into e.g. Notepad, and then save it as a *.bat file (e.g. "night-music.bat"). Then just double click it to run the script.

Cheers, Arite.

Re: VLC Timer?

Posted: 22 Jan 2010 22:21
by CheeseKing
Nice! I'll give the first one a shot, thanks. Unfortunately, I can't turn my computer off as I have hardware/software that will only work if it's on.

Re: VLC Timer?

Posted: 22 Jan 2010 22:41
by CheeseKing
Hey, it worked! Thanks! Is there any command line option I could use to set the volume to a certain level as well?

Edit: I did some Googling and found out that --volume is the correct command. What I find odd, however, is that the number you enter into the command line corresponds strangely with the percentage of volume that VLC starts out with. See, here's my command line:

"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" --input-repeat 60 --volume 194 C:\BabblingBrook.wav vlc://quit

I had to keep experimenting with the number I put after --volume to get it to set VLCs volume to 75%, as 75% was the volume percentage I wanted VLC to start out with when playing this batch file. I would have thought I could just put 75 after --volume and it would set the volume to 75%, but that was not the case. I'm still unsure as to why setting it to 194 would result in 75%, but it works, so who am I to complain. Perhaps someone could enlighten me about how the --volume command works.

Re: VLC Timer?

Posted: 23 Jan 2010 04:16
by Arite
Hey, it worked! Thanks!
Nice, glad it worked.
I had to keep experimenting with the number I put after --volume to get it to set VLCs volume to 75%, as 75% was the volume percentage I wanted VLC to start out with when playing this batch file. I would have thought I could just put 75 after --volume and it would set the volume to 75%, but that was not the case. I'm still unsure as to why setting it to 194 would result in 75%, but it works, so who am I to complain. Perhaps someone could enlighten me about how the --volume command works.
The reason 194 works is because the range of VLC's volume is from 0 to 1024. 1024 corresponds to 400%, hence 100% is 256. Therefore 192 is 75% (as 256*0.75 = 192).

Cheers, Arite.

Re: VLC Timer?

Posted: 23 Jan 2010 05:30
by CheeseKing
Well now, that makes sense now that it's been explained. Thanks again for the command line tip. I owe ya one. :)

Re: VLC Timer?

Posted: 26 Mar 2010 02:27
by taurusx5
If you wanted to shutdown you PC you could write a Batch script with a shutdown command after the VLC one. For example:

Code: Select all

"C:\Program Files\VideoLAN\VLC\vlc.exe" --input-repeat 9 C:\Temp\File.mp3 vlc://quit shutdown -s -t 0
Where "C:\Program Files\VideoLAN\VLC" is the location of VLC.

That should play the file 10 times in VLC, close VLC and then shutdown your computer. You can just write something like into e.g. Notepad, and then save it as a *.bat file (e.g. "night-music.bat"). Then just double click it to run the script.

Cheers, Arite.
Hi, Arite. I got a question about the command line you suggested to shut down the PC after VLC stops playing a file. Let's say that I run your script. But after say a month, I want my PC to return to normal. What script do I run to make my PC not shut down after playing a file in VLC?

.

Re: VLC Timer?

Posted: 26 Mar 2010 16:45
by Arite
The line which shuts down the PC is:

Code: Select all

shutdown -s -t 0
So if you don't want to shut down you PC just run the first line:

Code: Select all

"C:\Program Files\VideoLAN\VLC\vlc.exe" --input-repeat 9 C:\Temp\File.mp3 vlc://quit
^ That will still close VLC after playing the file (remove vlc://quit if you don't want to close VLC).

Arite.