3

I launched a subprocess to using its call method to play a video on Window Media Player.

eg. subprocess.call('"C:/Program Files (x86)/Windows Media Player/wmplayer.exe" "C:/Users/Public/Videos/Sample Videos/Wildlife.wmv"')

Now, how can I check if the playback is completed in the player for that particular video.

Is there is any direct Api available for the Windows Media Player Or there is a way to listen to the subprocess command launched using Popen

eg.

p = subprocess.Popen('"C:/Program Files (x86)/Windows Media Player/wmplayer.exe"  "C:/Users/Public/Videos/Sample Videos/Wildlife.wmv"')
# while the placback is happening
    p.wait()
# otherwise
    p.kill()
Matt
  • 74,352
  • 26
  • 153
  • 180
Program Questions
  • 440
  • 2
  • 6
  • 20

1 Answers1

1

Direct WMP Api:

subprocess.call('"C:/Program Files (x86)/Windows Media Player/wmplayer.exe" /play /close "C:/Users/Public/Videos/Sample Videos/Wildlife.wmv"')

adding /play /close will do the needful.

http://support.microsoft.com/KB/241422 for more options.

Hope it will help someone in future.

Program Questions
  • 440
  • 2
  • 6
  • 20
  • The linked article is for mplayer2, not wmplayer. /play /close are not valid options for wmplayer. See see this link for valid options for wmplayer.exe: https://msdn.microsoft.com/en-us/library/windows/desktop/dd562624(v=vs.85).aspx – Aron Curzon Dec 14 '15 at 19:24