mira te dejo este sencillisimo reproductor de mp3 espero que al menos lo leas para saber como se hace uno ok?
[code form1.cs]
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
namespace ReproductorMp3
{
/// <summary>
/// Descripción breve de Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.LinkLabel linkLabel1;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.LinkLabel linkLabel2;
private System.ComponentModel.IContainer components;
private System.Windows.Forms.StatusBarPanel statusBarPanel1;
private System.Windows.Forms.StatusBarPanel statusBarPanel2;
private System.Windows.Forms.StatusBarPanel statusBarPanel3;
private System.Windows.Forms.OpenFileDialog Of;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.StatusBar stMensajes;
private System.Windows.Forms.StatusBar stTiempos;
private System.Windows.Forms.TrackBar trackBar1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.LinkLabel linkLabel3;
// Creamos el objeto dela clase reproductor.
private Reproductor Sonido = new Reproductor();
// Una colección para agrupar los elementos listados.
private Hashtable hashMusica = new Hashtable();
// Bandera para informar sobre el arrastre del indicador de progreso.
private bool trackBarClick = false;
public Form1()
{
//
// Necesario para admitir el Diseñador de Windows Forms
//
InitializeComponent();
//
// TODO: Agregar código de constructor despuà ©s de llamar a InitializeComponent
//
}
/// <summary>
/// Limpiar los recursos que se està ©n utilizando.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// MÃ ©todo necesario para admitir el Diseñador, no se puede modificar
/// el contenido del mà ©todo con el editor de código.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.stMensajes = new System.Windows.Forms.StatusBar();
this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();
this.listBox1 = new System.Windows.Forms.ListBox();
this.linkLabel2 = new System.Windows.Forms.LinkLabel();
this.stTiempos = new System.Windows.Forms.StatusBar();
this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel();
this.statusBarPanel3 = new System.Windows.Forms.StatusBarPanel();
this.Of = new System.Windows.Forms.OpenFileDialog();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.trackBar1 = new System.Windows.Forms.TrackBar();
this.label1 = new System.Windows.Forms.Label();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.linkLabel3 = new System.Windows.Forms.LinkLabel();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
this.SuspendLayout();
//
// button1
//
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.button1.Location = new System.Drawing.Point(280, 56);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(88, 24);
this.button1.TabIndex = 1;
this.button1.Text = "&Reproducir";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.button2.Location = new System.Drawing.Point(280, 92);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(88, 24);
this.button2.TabIndex = 2;
this.button2.Text = "&Pausar";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.button3.Location = new System.Drawing.Point(280, 128);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(88, 24);
this.button3.TabIndex = 3;
this.button3.Text = "&Detener";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.button4.Location = new System.Drawing.Point(280, 168);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(88, 24);
this.button4.TabIndex = 4;
this.button4.Text = "&Salir";
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// linkLabel1
//
this.linkLabel1.Cursor = System.Windows.Forms.Cursors.Hand;
this.linkLabel1.Location = new System.Drawing.Point(8, 196);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Size = new System.Drawing.Size(56, 16);
this.linkLabel1.TabIndex = 5;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "Examinar";
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
//
// stMensajes
//
this.stMensajes.Location = new System.Drawing.Point(0, 264);
this.stMensajes.Name = "stMensajes";
this.stMensajes.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
this.statusBarPanel1});
this.stMensajes.ShowPanels = true;
this.stMensajes.Size = new System.Drawing.Size(380, 20);
this.stMensajes.TabIndex = 6;
this.stMensajes.Text = "statusBar1";
//
// statusBarPanel1
//
this.statusBarPanel1.BorderStyle = System.Windows.Forms.StatusBarPanelBorderStyle.None;
this.statusBarPanel1.Width = 200;
//
// listBox1
//
this.listBox1.HorizontalScrollbar = true;
this.listBox1.Location = new System.Drawing.Point(8, 56);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(260, 134);
this.listBox1.TabIndex = 7;
this.listBox1.DoubleClick += new System.EventHandler(this.listBox1_DoubleClick);
//
// linkLabel2
//
this.linkLabel2.Location = new System.Drawing.Point(68, 196);
this.linkLabel2.Name = "linkLabel2";
this.linkLabel2.Size = new System.Drawing.Size(92, 16);
this.linkLabel2.TabIndex = 8;
this.linkLabel2.TabStop = true;
this.linkLabel2.Text = "Quitar Elementos";
this.linkLabel2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel2_LinkClicked);
//
// stTiempos
//
this.stTiempos.Dock = System.Windows.Forms.DockStyle.Top;
this.stTiempos.Name = "stTiempos";
this.stTiempos.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
this.statusBarPanel2,
this.statusBarPanel3});
this.stTiempos.ShowPanels = true;
this.stTiempos.Size = new System.Drawing.Size(380, 20);
this.stTiempos.TabIndex = 9;
this.stTiempos.Text = "statusBar2";
//
// statusBarPanel2
//
this.statusBarPanel2.BorderStyle = System.Windows.Forms.StatusBarPanelBorderStyle.None;
this.statusBarPanel2.Text = "Tiempo Total:";
this.statusBarPanel2.Width = 180;
//
// statusBarPanel3
//
this.statusBarPanel3.BorderStyle = System.Windows.Forms.StatusBarPanelBorderStyle.None;
this.statusBarPanel3.Text = "Tiempo Transcurrido";
this.statusBarPanel3.Width = 180;
//
// timer1
//
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// trackBar1
//
this.trackBar1.AutoSize = false;
this.trackBar1.Location = new System.Drawing.Point(4, 224);
this.trackBar1.Name = "trackBar1";
this.trackBar1.Size = new System.Drawing.Size(368, 45);
this.trackBar1.TabIndex = 10;
this.trackBar1.TickStyle = System.Windows.Forms.TickStyle.None;
this.trackBar1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.trackBar1_MouseUp);
this.trackBar1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.trackBar1_MouseDown);
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(120, 16);
this.label1.TabIndex = 11;
this.label1.Text = "Lista de Reproducción";
//
// checkBox1
//
this.checkBox1.Location = new System.Drawing.Point(164, 32);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(108, 16);
this.checkBox1.TabIndex = 12;
this.checkBox1.Text = "Recorrer la lista";
//
// linkLabel3
//
this.linkLabel3.Location = new System.Drawing.Point(164, 196);
this.linkLabel3.Name = "linkLabel3";
this.linkLabel3.Size = new System.Drawing.Size(108, 16);
this.linkLabel3.TabIndex = 13;
this.linkLabel3.TabStop = true;
this.linkLabel3.Text = "Quitar Seleccionado";
this.linkLabel3.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel3_LinkClicked);
//
// Form1
//
this.AllowDrop = true;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(380, 284);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.linkLabel3,
this.checkBox1,
this.label1,
this.stTiempos,
this.linkLabel2,
this.listBox1,
this.stMensajes,
this.linkLabel1,
this.button4,
this.button3,
this.button2,
this.button1,
this.trackBar1});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Reproductor de mp3";
this.Closing += new System.ComponentModel.CancelEventHandler(this.Form1_Closing);
this.Load += new System.EventHandler(this.Form1_Load);
this.DragOver += new System.Windows.Forms.DragEventHandler(this.Form1_DragOver);
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.Form1_DragDrop);
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// Punto de entrada principal de la aplicación.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
// Inicializamos el panel de mensajes.
stMensajes.Panels[0].Text = "Listo";
// Asiganamos un manejador para el evento Mensajes del Reproductor.
Sonido.ReproductorEstado += new Reproductor.ReproductorMessage(this.MensajesDelReproductor);
// Establecemos la propiedad que permite seleccionar varios elementos
// en el cuadro de dialogo abrir.
Of.Multiselect = true;
//Verificamos el n
}