Python pause/resume media center?

Gigabyte / M52s-s3p
October 23, 2010 at 18:03:42
Specs: Microsoft Windows 7 Ultimate 32-Bit, 21.66 GHz / 1024 MB
Hey,
I was just wondering if it would be possible to pause or resume a video that is being played in windows media center (im assuming the command would be the same for media player). I'm not sure if this is possible. I have a keyboard with a pause button on it, so perhaps it is just a matter of telling python to press a key? .. i have no idea :P - thanks ahead.

ArukkNet Homepage -- My.. Under Construction Current Project.

Feel like helping? PM me.


See More: Python pause/resume media center?

Report •


#1
October 23, 2010 at 21:51:06
*sigh* I have to wake up in 4 hours, and I can't fall asleep. Well, it's good news for you, 'cause my sleep addled brain is your gain!

I wrote the following program in C, and it seems to work:

#include <windows.h>
int main() {
  ::SendMessage(0xffff, 0x319, 0, 0xE0000);
  return 0;
}
And apparently you can use Python's win32api.SendMessage to send the same message. I'd assume it would look something like this, but I don't know because I don't have Python installed:
import win32api
win32api.SendMessage(0xffff, 0x319, 0, 0xE0000)

How To Ask Questions The Smart Way


Report •

#2
October 25, 2010 at 22:22:59
Thanks tonnes for the fast response, i'm sorry it took so long for me to get back to you. The code you gave me to call in python seems to do what you said, however it seems to repeat the task in a loop until i end windows media center / player :P (it pauses then resumes non-stop, which brings cpu usage up past 100%) it definately seems to be on the right track though :) - i have basically no experience with C.. I booted up the express edition (I have no idea why it was installed on my computer, but i mustve used it for something), but failed to do anything other than confuse myself.. so thanks heaps for your help, but have you got any ideas on what i may be doing wrong..?

ArukkNet Homepage -- My.. Under Construction Current Project.

Feel like helping? PM me.


Report •

#3
October 26, 2010 at 21:20:49
With Python? You probably put the command in some sort of loop. Possibly an extremely fast loop, constrained only by the speed of win32api.SendMessage(). ::SendMessage() is a one-shot command, and I'd assume win32api does little more than wrap the C API.

As for VC++ Express, no. I'm not sure what you're doing: right, wrong, or otherwise.

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
October 26, 2010 at 23:43:18
Thanks for getting back to me :) .. I tested your code exaclty again from the python command line. It does pause like you said, sadly however it takes 5-6 seconds for it to completly pause, as it just seems to make the program lag really, really bad before it pauses :P, and the play pause button alternates really fast (maybe 15/sec) so i'm assuming its just pausing and resuming constantly.. im not entirely sure.. I have only tested it on one computer, too.. so it may just be the configuration or something.. if you have any other ideas, please let me know :P if not, thanks heaps for your help, ill just make do and hope its just my computer :P

ArukkNet Homepage -- My.. Under Construction Current Project.

Feel like helping? PM me.


Report •

#5
October 27, 2010 at 13:15:21
If your system has trouble running Python and play a video at the same time, I suggest you use a language with less overhead. C's the obvious choice, but the learning curve is near vertical.

How To Ask Questions The Smart Way


Report •

#6
November 3, 2010 at 22:54:03
hey again,
Sorry it took so long for me to reply, my project went on hold for a little while. Thanks heaps man, you gave me the base-code and a topic for research, and i just managed to find an address after about two hours of testing :P

import win32api
win32api.SendMessage(0xffff, 0x0111, 0x00004978, 0x00000000)

pauses/plays/resumes/whatevers media center perfectly without lag on windows 7. Maybe the address was different for the latest version of wmplayer? i'm not sure. but thanks heaps for your help, i couldnt've gotten anywhere without you :)

ArukkNet Homepage -- My.. Under Construction Current Project.

Feel like helping? PM me.


Report •


Ask Question