Playing Audio and Video Files In ASP.NET

  • Anbu
  • Anbu
  • Updated date, Aug 25, 2019

Playing audio and video files in an ASP.NET Web application using C#.Net and mediaplayer.dll


To create simple media player in ASP.NET Web Application.

Steps for adding 'Windows Media Player' control (COM component) into Toolbox

  1. By default, Windows Media Player control is not provided in the toolbox
  2. If Add Right Click The any Tab in ToolBox Window

  3. Then Select Choose Items

  4. Then the following window is Appear on screen

  5. Select Windows Media Player Check box in Com components
  6. Finally get windows media player Tool in Tool Box

  7. Drag and Drop the media player Tool from ToolBox to Window Form

  8. Add OpenFileDialog to Form by double Click the openFiledialog in Toolbox tab dialogs
  9. Add Button to window form and change the text property as Addplaylist

On the button click event handler, add the following code

  1. private void button1_Click(object sender, EventArgs e)  
  2. {  
  3.    openFileDialog1.Filter = "(mp3,wav,mp4,mov,wmv,mpg)|*.mp3;*.wav;*.mp4;
       *.mov;*.wmv;*.mpg|all files|*.*"
  4.    if (openFileDialog1.ShowDialog() == DialogResult.OK)  
  5.    axWindowsMediaPlayer1.URL = openFileDialog1.FileName;  
  6. }