1 Replies - 1963 Views - Last Post: 09 May 2009 - 01:13 AM Rate Topic: -----

#1 ADK_007  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 17-April 09

Help- i need to set the media player size fixed in C#

Posted 09 May 2009 - 12:05 AM

I added windows media player to my program and when i play a song, it is automatically resizing according to the song. Specially when i play a video it is changing according to it's resolution. I need to set the window size fix please help me....

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

namespace Ya_fm
{
	public partial class Frm_ply_sng : Form
	{
		string fullpath;

		public Frm_ply_sng()
		{
			InitializeComponent();
		}

		private void Frm_conductor_help_Load(object sender, EventArgs e)
		{
			WindowsMediaPlayer1.Visible = true;
			WindowsMediaPlayer1.settings.autoStart = false;
		}

	   
		private void button1_Click(object sender, EventArgs e)
		{
			try
			{
				OpenFileDialog opn_song = new OpenFileDialog();

				opn_song.Filter = " Music Files(*.mp3,*.wav,*.avi,*.mpeg,*.wmv)|*.mp3;*.wav,*;avi;*.mpeg;*.wmv;";
				if (opn_song.ShowDialog() == DialogResult.OK)
				{
					fullpath = System.IO.Path.GetFullPath(opn_song.FileName);
				}
				WindowsMediaPlayer1.Visible = true;
				WindowsMediaPlayer1.settings.autoStart = true;
				WindowsMediaPlayer1.URL = fullpath;
			}
			catch (Exception)
			{
				throw new ApplicationException("Failed loading Song");
			}
		}

				  
	}



this is my code please help me.......

Is This A Good Question/Topic? 0
  • +

Replies To: Help- i need to set the media player size fixed in C#

#2 Mezius  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 68
  • Joined: 13-April 09

Re: Help- i need to set the media player size fixed in C#

Posted 09 May 2009 - 01:13 AM

There's two ways you can do this.

One: If you're adding the control through the GUI editor, you can right click the WMP control and click properties. Under properties you'll find a few different options.
-Locked(bool)
-Stretchtofit(bool)
-MaximumSize(int) in pixels

You can change these to set the size of the control and prevent it from changing sizes.

You can also add code similar to this to your program if you aren't using the GUI to code that piece.
			MediaPlayer.stretchToFit = false;
			MediaPlayer.MaximumSize.Height = 120;
			MediaPlayer.MaximumSize.Width = 120;


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1