I would like to play a video using c/c++ program..

what libraries should i include??

can anyone tell the code....

This would depend on the kind of video... A flash video? HTML 5?? What Codecs?? AVI? WMV? MP4? What kind.. There is no specific code to play every single type of video that exists..

This would depend on the kind of video... A flash video? HTML 5?? What Codecs?? AVI? WMV? MP4? What kind.. There is no specific code to play every single type of video that exists..

any video file like .avi or .swf file etc..

Create a Windows Form application (CLR - Windows Form Application). Right click on Tools box to add a new COM component. Select Windows Media Player, check it and push OK. It will be added to Toolbox.
Draw a Media Player control on the form. In the Property Box set the property URL to the pathname of the file you want to play. You can also set this property programatically.
For example, if you add an openFileDialog control to choose the file and a button, you can write the following code for the event click of the button:

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
    openFileDialog1->ShowDialog();
    axWindowsMediaPlayer1->URL = openFileDialog1->FileName;  }

Edited 3 Years Ago by mike_2000_17: Fixed formatting

if you are running windows, and are willing to compromise a bit, you could use a batch file to help you out, in your c++ code, type:
system("example.bat");
then open notepad and type:
start filename.any
and save it as example.bat

AVI code as follows.

The way AVI played and controlled is similar with audio files, you can set parameter uMsg in function mciSendCommand as avivideo. Here is the code.

else if(strcmp(pFileExt,"AVI") == 0 || strcmp(pFileExt,"avi") == 0){
    mciOpenParms.lpstrDeviceType = "avivideo";
    type = AVI;
}
This article has been dead for over six months. Start a new discussion instead.