Is there a way to play/pause and stop video using C++

Hello there,
I was wondering if you guys know how to use play/pause and stop videos using the command window.

What I want to try and do is to open a video and then use the command window in visual studio to play/pause and stop the video any time I press a key such as p(pause), s(stop) etc.

I'm using windows media player to play the file.
here's the code on how I opened it.
system("start C:\\Music_Videos\\Girls_Generation-hoot_SHORT.wmv");

I'm currently trying to pause the video after it has been opened but it is not currently working. More specifically the video is not pausing.

my initial values
1
2
int count = 0;
char letter[STRING_LENGTH];


here's my code for attempting to pause the command but it is not working.
After line 9 where I finished typing in a latter it just reverts back to asking if I would like to input a command.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
			while (zgb_rx_check() == 0)
			{
				// countinually check for data indicating dance has stopped

				while (count == 0 || count == 1)
				{
					//Check_if_finished();
					cout << "\n\n Would you like to input a command? \n"; // asks for a command (pause command)
					scanf("%c", &letter);
					gets(letter);
					count = findletter(letter);

					if (count = 0)
					{
					}
					else if (count = 1)
					{	
						system("pause C:\\Music_Videos\\Girls_Generation-hoot_SHORT.wmv");
					}

				}
			}


and my call function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int findletter(char letter[])
{
	int value;


	if (letter[0] == 'P' || letter[0] == 'p')
	{
		value = 1;
	}

	else if (letter[0] != 'P' || letter[0] != 'p')
	{
		value = 0;
	}

		return value;
}


I already know the reasons why not to use the system() but I find it difficult trying to implement it when it is pausing the video so I resorted to the system() function.

What I want to know is if there's anything wrong with this code since I can't pause the video in the command window or if there's a better way to implement it rather than using my code.

Opinions regarding this are very much appreciated,
Thanks
Last edited on
A simple Google search for "Windows Media Player C++ API" gave me this as the first hit:

http://msdn.microsoft.com/en-us/library/windows/desktop/dd564580%28v=vs.85%29.aspx
I've read that as well but it doesn't give me any specific details on how to implement the play/pause/stop commands
Clicking through to:

http://msdn.microsoft.com/en-us/library/windows/desktop/dd563068%28v=vs.85%29.aspx

gives you a load of interfaces you can use to control the WMP. I'm guessing you'll need to be familiar with with whatever Microsoft frameworks are involved. Really, this is a question for the Windows Programming forum.
There we go, I moved it to the Windows Forum.
I'll take a look at the link you provided as well.
Topic archived. No new replies allowed.