How to play video file repeatedly using command prompt

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
rajeev
Posts: 9
Joined: 10 May 2012 04:26

How to play video file repeatedly using command prompt

#1 Post by rajeev » 10 May 2012 08:01

Guys,

I need to run a video file through command prompt enabling "repeat"...
Could some one please help me.. ASAP

Thanks in Advance!! :)

Fawers
Posts: 187
Joined: 08 Apr 2012 17:11
Contact:

Re: How to play video file repeatedly using command prompt

#2 Post by Fawers » 10 May 2012 08:04

What do you mean by "repeat"?

Enable "repeat" feature from media player OR play the video file again when the media is closed?

rajeev
Posts: 9
Joined: 10 May 2012 04:26

Re: How to play video file repeatedly using command prompt

#3 Post by rajeev » 10 May 2012 08:12

Thanks for the quick response Fawers!!

Basically, to Enable "repeat" from media player. But both sounds similar..

I have a different script which executes for more than 30mins, where i need to run video content on background in parallel which is 2min long.. So , i need to repeat the content untill script
ends

Fawers
Posts: 187
Joined: 08 Apr 2012 17:11
Contact:

Re: How to play video file repeatedly using command prompt

#4 Post by Fawers » 10 May 2012 08:29

I see.
I don't think it's possible, but can one activate "repeat" in this media player with command line parameters? I can't think of other way to enable it via batch.

Everything below this line must be read assuming you can't enable "repeat" with CL parameters.

By the way, let's assume 3 other things:
1. You're using media player classic (executable name: "mpc hc.exe")
2. The video file is in the same folder as mpc hc.exe and its name is "video file.avi"
3. The batch script is in the same folder as mpc hc.exe

You said the video has 2 minutes; we can do something like this:

Code: Select all

@echo off
set "n=15"
::n is the number of times you want the video to loop
::if program = 30mins of lenght and video = 2mins, then n should be 15
for /l %%n in (1 1 %n%) do (
start "" "mpc hc.exe" "video file.avi"
>nul ping -n 121 localhost
taskkill /f /im "mpc hc.exe"
)

Let's call this script "play_video.bat".

And you would probably have to start it from another batch.
Once again, assuming it is in the same folder as the others (otherwise, write the full path to play_video.bat)
Main batch:

Code: Select all

@echo off
:video
start /min play_video.bat
if not %errorlevel% == 0 goto video

:YourCode
::your code here

rajeev
Posts: 9
Joined: 10 May 2012 04:26

Re: How to play video file repeatedly using command prompt

#5 Post by rajeev » 10 May 2012 08:39

Awesome..!!!

But, the real problem is there will be multiple windows opened and there might be a delay in opening
file due to the other vbscript running in the background..

Thanks a lot.. Fawers!!! :D

Fawers
Posts: 187
Joined: 08 Apr 2012 17:11
Contact:

Re: How to play video file repeatedly using command prompt

#6 Post by Fawers » 10 May 2012 08:43

rajeev wrote:But, the real problem is there will be multiple windows opened and there might be a delay in opening
file due to the other vbscript running in the background..

You can change the FOR loop PING delay, if you wish to.

Remember: imagination is our only limit. :wink:

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: How to play video file repeatedly using command prompt

#7 Post by aGerman » 10 May 2012 11:47

There is no command line option to enable the loop mode for WMPlayer. The only possibility is to change the registry setting before you run it.
Tested on my Win7 (x86) with WMP version 12:

Code: Select all

:: turn on loop mode
reg add "HKCU\Software\Microsoft\MediaPlayer\Preferences" /v "ModeLoop" /t REG_DWORD /d 1 /f

:: turn off loop mode
reg add "HKCU\Software\Microsoft\MediaPlayer\Preferences" /v "ModeLoop" /t REG_DWORD /d 0 /f

Of course that has no effect if the WMP is already running.

Regards
aGerman

rajeev
Posts: 9
Joined: 10 May 2012 04:26

Re: How to play video file repeatedly using command prompt

#8 Post by rajeev » 16 May 2012 00:22

aGerman wrote:There is no command line option to enable the loop mode for WMPlayer. The only possibility is to change the registry setting before you run it.
Tested on my Win7 (x86) with WMP version 12:

Code: Select all

:: turn on loop mode
reg add "HKCU\Software\Microsoft\MediaPlayer\Preferences" /v "ModeLoop" /t REG_DWORD /d 1 /f

:: turn off loop mode
reg add "HKCU\Software\Microsoft\MediaPlayer\Preferences" /v "ModeLoop" /t REG_DWORD /d 0 /f

Of course that has no effect if the WMP is already running.

Regards
aGerman



Great!!! :)
Simple & Perfect.. It's working ..

Thanks a lot...aGerman

Post Reply