Playing audio and video files in an ASP.NET Web application using C#.Net and mediaplayer.dll
Objective
To create simple media player in ASP.NET Web Application.
Steps for adding 'Windows Media Player' control (COM component) into Toolbox
- By default, Windows Media Player control is not provided in the toolbox
- If Add Right Click The any Tab in ToolBox Window
- Then Select Choose Items
- Then the following window is Appear on screen
- Select Windows Media Player Check box in Com components
- Finally get windows media player Tool in Tool Box
- Drag and Drop the media player Tool from ToolBox to Window Form
- Add OpenFileDialog to Form by double Click the openFiledialog in Toolbox tab dialogs
- Add Button to window form and change the text property as Addplaylist
On the button click event handler, add the following code
- private void button1_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;
- }