• Advertisement
Sign in to follow this  

start windows media-player by the console

This topic is 4710 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello collegues, as an intro for my little game, i want to play an (selfmaded :)))) ) video .avi. That mean's, when the player start the game by pressing s, the windows media-player opens and the startfilm is shown. Which is the console-command to play a film on windows media-player? Thank you verry for your help, hick

Share this post


Link to post
Share on other sites
Advertisement
I don't have Windows Media Player installed at the moment so I can't test the following but I think this is the command to launch Windows Media Player and a media file from the console/Run under Windows 98 at least:

mplayer C:\Sound.wav

If you're programming in C++ you could include cstdlib and call system("mplayer C:\Sound.wav") or Shell if it's VB you're using.

Also, you could consider using mciSendString (win32 function - include windows.h) which supports many types of media files and can automatically create a scalable window to play the media file in (if it's a movie):

//open the movie
mciSendString("OPEN movie.avi TYPE MPEGVIDEO ALIAS movie1", NULL, 0, NULL);
//play it from frame 0
mciSendString("PLAY movie1 FROM 0", NULL, 0, NULL);

//and when you're done close the movie:
mciSendString("STOP movie1", NULL, 0, NULL);
mciSendString("CLOSE movie1", NULL, 0, NULL);

As you see, the file name is used to open the file and create an alias, then the alias is used to play, stop and close the file.

MSDN:
win32 mcisendstring

Good luck!

\Jimmy H

Share this post


Link to post
Share on other sites
@ Jimy H,

thank your verry much for the help!!!

I will make a frame and start the film in the frame, but since I am only dealing with the console, I dont now, how I can make a freame.

@ all,

can perhaps someone show me, how I can make a frame at a specific position, with a specific length and width? Because I have a graphic card, with two monitors attached and I want to show the film only on the second monitor, but in full screen. But the second one is an old one with an resolution of 600x800:)))))

i think, when i make a frame, 600x800 with an initial position at the upper right position of the master-monitor, then I can show on the slave-screen a full-screen movie:)))))))))

what you think on this idea?

thank you verry much for reply,

hick

Share this post


Link to post
Share on other sites
You could also start the user's default AVI viewer by passing the filename to ShellOpen( ... ). This is the standard way and more friendly, since it does not rely on WMP to be present.

Greetz,

Illco

Share this post


Link to post
Share on other sites
@ Illco,

that mean's I can write on my cpp-program ShellOpen(filename.avi) and the standart-player will open and plays the .avi file?

How can I change the position of the standart-player-field?

When the standart-player is already open, can I then also play another film, that gives me the possibility for sequel-sequences on my little cpp-game ;)))))


thank you verry much for all your help

sincerly,

Hick

Share this post


Link to post
Share on other sites
You can, assuming that you are writing a Windows program (which seems most appropriate when using WMP). I thought it was ShellOpen, but otherwise it is something like that; look it up in the docs. As to how to go about actually interacting with the created instance of the player: I don't know.

Greetz,

Illco

Share this post


Link to post
Share on other sites
@ Illco,

Thank's a lot for the reply, but what you think about the idea to make a separate frame and to show the film in the frame?

Like I have told some postings befor, but for the moment, I dont know, how to make a frame:((( can you help me with a bit code?

thank you all,

Hick

Share this post


Link to post
Share on other sites
Hey. Can't one play video files through DirectX, or something like that. Alas, that maybe be what you were intented.

Share this post


Link to post
Share on other sites
I guess there's code for an AVI player in the NeHe tutorials. Lesson 35, if I'm not mistaken. It uses OpenGL, though.

Son Of Cain

Share this post


Link to post
Share on other sites
@ danne89 and Son of Chain,

Thank you verry much for all your help.

But when I read the post from Jimmy H, it seem's to bee quite easy to play a fiedeo in a frame, so I am just wondering, how I can make such a frame. I think it will bee a normal frame, isn't it?


thank's for code and help,

hick

Share this post


Link to post
Share on other sites
If you just want to display a video within your DX application, check out DirectShow. It comes with a lot of samples doing that and more.

Greetz,

Illco.

Share this post


Link to post
Share on other sites
@ Illco,

thank's a lot, I have to test it out!!!

I will post, if i reached or when I have problems.

see you,

hick

Share this post


Link to post
Share on other sites
Quote:
Original post by Hick
@ danne89 and Son of Chain,

Thank you verry much for all your help.

But when I read the post from Jimmy H, it seem's to bee quite easy to play a fiedeo in a frame, so I am just wondering, how I can make such a frame. I think it will bee a normal frame, isn't it?


thank's for code and help,

hick


Sorry for my absence. It actually is quite easy to play a video in a window. You don't have to create a window if you don't want to. mciSendString will automatically create one for the avi file to be played in, even if it's called from within a console application.

Here's an example:


#include <windows.h> //mciSendString is in windows.h

//console application entry function
int main(int argc, char** argv)
{
/* movie.avi is the file name, it's supposed to be in the same directory
as the executable
mpegvideo type works for most media file types
movie1 is the alias which will be used later in mciSenString calls */

mciSendString("OPEN movie.avi TYPE MPEGVIDEO ALIAS movie1", NULL, 0, NULL);

//play the file with the alias movie1 from it's first frame (from the beginning)
mciSendString("PLAY movie1 FROM 0", NULL, 0, NULL);

/* send a pause command to the console so we have time to watch the movie
it will probably say something like "press any key to continue" */

system("pause");

//stop the movie and close it
mciSendString("STOP movie1", NULL, 0, NULL);
mciSendString("CLOSE movie1", NULL, 0, NULL);

return 0;
}



Note that mciSendString is forward referenced in windows.h, and exists in winmm.lib, so you have to link to winmm.lib in your compiler/linker before you build the program. In Visual Studio 6.0 do this in the menu Project/Project Settings/Link, in the Object/library modules edit box (General Category). Add winmm.lib in the edit box. Read about how to link to libraries for the compiler you're using.

\Jimmy H

Share this post


Link to post
Share on other sites
Hey

This may help you a bit.

If you want to explor directshow check this out.
http://msdn.microsoft.com/library/en-us/directshow/htm/howtoplayafile.asp

This shows you a directshow app that plays a file. Very nice and simple:)

Good luck,

Share this post


Link to post
Share on other sites
Dear collegues,

I have decided, to change my little game:

When the game is started, the gamer see on the main-screen his game and on the second screen right, a normal image or when the gamer reach a special place, then on the right monitor is a film played.

For this, I want to use the idea from Jimmy H:

create a frame with the original point at the right upper corner from the main-Screen (so the frame is visible at the right screen), show an image in this frame and on special keyboard-imput from the gamer, show an film on this right frame.

so:

1) how can I make a frame at the position right upper corner

2) how can I show a normal .jpg file on this frame,

3) is the following code correct for playing a film in the right frame?
mciSendString("OPEN movie.avi TYPE MPEGVIDEO ALIAS movie1", RightFrame, 0, NULL);


Thank you verry much for help,

sincerly,

Hick

p.s. I think it would bee interesting for everyone, to have an startvideo. Also why mostly all people have a digicam and can make their own homevideo sequence-trials.

Share this post


Link to post
Share on other sites
Quote:
Original post by fimdan
Hey

This may help you a bit.

If you want to explor directshow check this out.
http://msdn.microsoft.com/library/en-us/directshow/htm/howtoplayafile.asp

This shows you a directshow app that plays a file. Very nice and simple:)

Good luck,


Including great Microsoft example code:

#include <dshow.h>
void main(void)
{ ...


[grin]

Share this post


Link to post
Share on other sites
@ Prototype,

Thank's for the help, but it is not the way, which I am interested in. I want to do it with a simple frame.

@ all,

1) how can I make a frame at the position right upper corner

2) how can I show a normal .jpg file on this frame,

3) is the following code correct for playing a film in the right frame?
mciSendString("OPEN movie.avi TYPE MPEGVIDEO ALIAS movie1", RightFrame, 0, NULL);

thank's a lot for specific help,

Sincerly,

Hick

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement