I want to creat music player in c#. I seachered in net, I got the solution but after that in that code I want to add seek bar and a lable that will show the time of the song.
The code is like this....
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace Mithlesh_MP3Player
{
public partial class Form1 : Form
{
[DllImport("winmm.dll")]
private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback);
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
FilenameTextbox.Text = openFileDialog1.FileName;
button3.Enabled = true;
}
}
private void button2_Click(object sender, EventArgs e)
{
mciSendString("open \"" + FilenameTextbox.Text + "\" type mpegvideo alias MediaFile", null, 0, IntPtr.Zero);
mciSendString("play MediaFile", null, 0, IntPtr.Zero);
button3.Enabled = true;
button2.Enabled = false;
}
private void button3_Click(object sender, EventArgs e)
{
mciSendString("close MediaFile", null, 0, IntPtr.Zero);
button2.Enabled = true;
button3.Enabled = false;
}
}
}
Plz also explain this code..
private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback);
[edit]Code block added - OriginalGriff[/edit]
thans in advans!