List of Exercises

How to Create Windows Media Player in WinForms C#

	    
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Video_Media_Player
{
  public partial class Form1 : Form
  {
    private Size formOriginalSize;
    private Rectangle recMP;
    public Form1()
    {
      InitializeComponent();
      this.Resize += Form1_Resize;
      formOriginalSize = this.Size;
      recMP = new Rectangle(axWindowsMediaPlayer1.Location, axWindowsMediaPlayer1.Size);
    }

    void Form1_Resize(object sender, EventArgs e)
    {
      resize_Control(axWindowsMediaPlayer1, recMP);
    }
    private void resize_Control(Control c, Rectangle r)
    {
      float xRatio = (float)(this.Width) / (float)(formOriginalSize.Width);
      float yRatio = (float)(this.Height) / (float)(formOriginalSize.Height);
      int newX = (int)(r.X * xRatio);
      int newY = (int)(r.Y * yRatio);

      int newWidth = (int)(r.Width * xRatio);
      int newHeight = (int)(r.Height * yRatio);

      c.Location = new Point(newX, newY);
      c.Size = new Size(newWidth, newHeight);

    }
    private void select_video_Click(object sender, EventArgs e)
    {
      OpenFileDialog opf = new OpenFileDialog();
      if (opf.ShowDialog() == DialogResult.OK)
      {
        axWindowsMediaPlayer1.URL = opf.FileName;
      }
    }
  }
}
		
	 


Download the project of Visual Studio 2013 in DropBox Download


How to Make Windows Media Player on WinForms C# | Playing Audio and Video


Video Thumbnail