Description:-
To develop a windows application for playing audio and video files using c#.net.
->‘Windows Media Player’ control will appear in the toolbox.
Output:
To develop a windows application for playing audio and video files using c#.net.
Design:
and ‘Windows Media Player’ contol (COM
component).
Note that OpenFileDialog control appears below
the form(not on the form), which is used in our application for browsing
audio/video files.
Steps for adding ‘Windows Media Player’ control
(COM component) into Toolbox:
By default, ‘Windows Media Player’
control is not provided in the toolbox,
we have to add it into the
toolbox if required.
Inorder to add ‘Windows
Media Player’ control into toolbox Right click on ‘General’ tab (or anyother
tab) in toolbox
->select ‘Choose
Items...’
->select
‘COM Components’ tab
->select
‘Windows Media Player’
->click
on ‘OK’ button.
->‘Windows Media Player’ control will appear in the toolbox.
Now, drag ‘Windows Media
Player’ control on to the form and place a button on it with text as Browse..’
as shown in the design.
Code:
using System; using System.Windows.Forms; namespace mymediaplayer { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btnBrowse_Click(object sender, EventArgs e) { openFileDialog1.Filter = "(mp3,wav,mp4,mov,wmv,mpg)|*.mp3;*.wav;*.mp4;*.mov;*.wmv;*.mpg|all files|*.*"; if(openFileDialog1.ShowDialog()==DialogResult.OK) axWindowsMediaPlayer1.URL = openFileDialog1.FileName; } } }
Output:
Thanks for comments.....