Hello Readers
This is the source code for mp3 player in C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Mp3_player
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
axWindowsMediaPlayer1.URL = paths[listBox1.SelectedIndex];
axWindowsMediaPlayer1.windowlessVideo = true;
}
catch (Exception ex)
{
MessageBox.Show("Error in playing ");
}
}
string[] files, paths;
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog opn = new OpenFileDialog();
opn.Filter = "MP3|*.mp3|ALL files |*.*";
opn.Title = "Select the file to play";
opn.Multiselect = true;
if (opn.ShowDialog() == DialogResult.OK)
{
files = opn.SafeFileNames;
paths = opn.FileNames;
for (int i = 0; i < files.Length; i++)
{
listBox1.Items.Add(files[i]);
}
}
}
private void listBox1_StyleChanged(object sender, EventArgs e)
{
}
private void creditsToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("Developed by ",MessageBoxButtons.OK);
}
private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
}
}
}
Output:-
This is the source code for mp3 player in C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Mp3_player
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
axWindowsMediaPlayer1.URL = paths[listBox1.SelectedIndex];
axWindowsMediaPlayer1.windowlessVideo = true;
}
catch (Exception ex)
{
MessageBox.Show("Error in playing ");
}
}
string[] files, paths;
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog opn = new OpenFileDialog();
opn.Filter = "MP3|*.mp3|ALL files |*.*";
opn.Title = "Select the file to play";
opn.Multiselect = true;
if (opn.ShowDialog() == DialogResult.OK)
{
files = opn.SafeFileNames;
paths = opn.FileNames;
for (int i = 0; i < files.Length; i++)
{
listBox1.Items.Add(files[i]);
}
}
}
private void listBox1_StyleChanged(object sender, EventArgs e)
{
}
private void creditsToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("Developed by ",MessageBoxButtons.OK);
}
private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
}
}
}
Output:-
1 comments:
Is your code complete?
Post a Comment