Frege wegen c#

Tobi

Mitglied
Hi alle zusammen habe mal ne frage und zwar: Kann man in c# auch eine art win amp programmieren (halt einen player der mp3´s abspielt) ?
und hat jemand von euch schon mal so was in c# gemacht?
 
Hi Tobi!

Deine Frage hat wenig mit C# zu tun, denn du kannst in fast jeder Sprache einen Mp3-Player programmieren, nur brauchst du die Decodieralgorithmen.
Falls du die haben solltest sag mir bitte bescheid. Ich hatte nämlich auch mal vor so ein Ding zu porgrammieren, hab die Algorithmen nur nicht gefunden.

Viel Spass
archimedes
 
MP3

Hallo zusammen...

Ein einfacher Weg um MP3´s zu spielen ist dieser...
Viel Spass noch

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Text;

namespace cyriousMP3
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button btnOpen;
private System.Windows.Forms.Button btnPlay;
private System.Windows.Forms.Label lblCurrnt;
private System.ComponentModel.IContainer components;

private OpenFileDialog file = new OpenFileDialog();

private string CommandString;
private System.Windows.Forms.Timer timer1;
private int seconds;
private int minutes;

StringBuilder buffer = new StringBuilder(128);

[DllImport("winmm.dll")]
private static extern long mciSendString(string lpstrCommand, StringBuilder lpstrReturnString, int uReturnLength, int hwndCallback);

public Form1()
{
InitializeComponent();
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.btnOpen = new System.Windows.Forms.Button();
this.btnPlay = new System.Windows.Forms.Button();
this.lblCurrnt = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
//
// btnOpen
//
this.btnOpen.Location = new System.Drawing.Point(56, 16);
this.btnOpen.Name = "btnOpen";
this.btnOpen.Size = new System.Drawing.Size(72, 24);
this.btnOpen.TabIndex = 0;
this.btnOpen.Text = "öffnen";
this.btnOpen.Click += new System.EventHandler(this.btnOpen_Click);
//
// btnPlay
//
this.btnPlay.Location = new System.Drawing.Point(168, 16);
this.btnPlay.Name = "btnPlay";
this.btnPlay.Size = new System.Drawing.Size(72, 24);
this.btnPlay.TabIndex = 1;
this.btnPlay.Text = "spielen";
this.btnPlay.Click += new System.EventHandler(this.btnPlay_Click);
//
// lblCurrnt
//
this.lblCurrnt.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblCurrnt.Location = new System.Drawing.Point(96, 48);
this.lblCurrnt.Name = "lblCurrnt";
this.lblCurrnt.Size = new System.Drawing.Size(96, 24);
this.lblCurrnt.TabIndex = 2;
this.lblCurrnt.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// timer1
//
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 86);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.lblCurrnt,
this.btnPlay,
this.btnOpen});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Name = "Form1";
this.Text = "cyriousX mp3";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);

}
#endregion

[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void btnOpen_Click(object sender, System.EventArgs e)
{
file.Filter = "Mp3 files |*.mp3";
if(file.ShowDialog() == DialogResult.OK)
{
CommandString = "close Mp3File";
mciSendString(CommandString,null,0,0);

timer1.Enabled = false;

CommandString = "open " + "\"" + file.FileName + "\"" + " type MPEGVideo alias Mp3File";
mciSendString(CommandString,null,0,0);
}
}

private void btnPlay_Click(object sender, System.EventArgs e)
{
if(file.FileName == "")
{
file.Filter = "Mp3 files |*.mp3";
if(file.ShowDialog() == DialogResult.OK)
{
CommandString = "open " + "\"" + file.FileName + "\"" + " type MPEGVideo alias Mp3File";
mciSendString(CommandString,null,0,0);

CommandString = "play Mp3File";
mciSendString(CommandString,null,0,0);

timer1.Enabled = true;
}
}

else
{
CommandString = "play Mp3File";
mciSendString(CommandString,null,0,0);

timer1.Enabled = true;
}

}

private void timer1_Tick(object sender, System.EventArgs e)
{
CommandString = "Status Mp3File position";
mciSendString(CommandString, buffer, 128, 0);
seconds = int.Parse(buffer.ToString());
seconds = seconds / 1000;

minutes = seconds / 60;
seconds = seconds % 60;
lblCurrnt.Text = minutes.ToString("00") + ":" + seconds.ToString("00");
}

private void Form1_Load(object sender, System.EventArgs e)
{

}
}
}
 
Zurück