How to Play a Video in windows Application and web application

Today i want to present a topic regarding about playing video files in your Windows Application and as well as Web Application.This topic covers how to add a reference Media player dll to your project,what are the propeties that we can set to the windows Media player Control in Windows Application.How to stop the video in Windows Media player.How to embed the source of Object in your webpage These are the topics i will describe in this article with snippet of code lines.

Windows Application does n't have a general windows media player control (available in tool box) to play a video.So we have to add a reference from COM Component tab.You can add the reference from the Project and go to com component tab add the windows media player compnent from there.

1)Right-click within the Toolbox, and then select Choose Items. This opens the Customize Toolbox dialog box.

2)In the COM Components tab, select Windows Media Player.
If Windows Media Player does not appear in the list, click Browse, and then open Wmp.dll, which should be in the Windows\System32 folder.

3)Click OK. The Windows Media Player control will be placed on the current Toolbox tab.

After adding the control in the form you can set the Visible,size.hieght,size.width

Add the Video Window

after adding the reference than you have to import the namespace in your code

using WMPLib;

AxWindowsMediaPlayer AxWindowsMediaPlayer1;

AxWindowsMediaPlayer1.URL = "c:\hi.wmv"

To stop the Player


You can get Current Play List

WMPLib.IWMPPlaylist firstPlaylist = player.playlistCollection.getAll().Item(0);

// Make the retrieved playlist the current playlist.

player.currentPlaylist = firstPlaylist;

if (player.playState == WMPLib.WMPPlayState.wmppsPlaying)
player.fullScreen = true;

you can close the Windows media player


In webApplication or webpage You can embed the Windows Media Player ActiveX control in a webpage using the following four steps

They start with begin tag and ends with end tag

OBJECT ID="Player" height="0" width="0"
end of the object tag /OBJECT

You can set the property url as one of the attribute in the tag.The URL path define the path of Media file.

OBJECT ID="Player" height="0" width="0"
url="hi.wmv" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">

In the Code You can define...

Player.URL = "Hi.wmv";


Article by srirama
A Good advice from parent to a Child , Master to a Student , Scholar to an Ignorant is like a doctor prescribed pill it is bitter to take but when they take it will do all good for them --- Bhushan

Follow srirama or read 74 articles authored by srirama


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: