Previous..
Next...
Here i will explain MP3 media Player in window application.
Step(1) :- Form
Before reading this artical 1st go on tutorial 37.
here we will take a listBox and a button for adding playlist in listbox.
Step(2) :- Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text;
using System.IO;
using System.IO;
namespace First_Csharp_app
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
String [] files , paths;
//At Choose button
private void Choose_Btn_click(object sender, EventArgs e)
{
OpenFileDialog openfile = new OpenFileDialog ();
if(openfile .ShowDialog() ==System.Window.Forms.DialogResult.OK)
{
{
OpenFileDialog openfile = new OpenFileDialog ();
if(openfile .ShowDialog() ==System.Window.Forms.DialogResult.OK)
{
textBox1.Text = openfile .FileName;
}
}
//At Start button
private void Start_Btn_click(object sender, EventArgs e)
{
{
axWindowMediaPlayer1.URL = textBox1.Text;
axWindowMediaPlayer1.Ctlcontrols.play();
}
//At Stop button
private void Stop_Btn_click(object sender, EventArgs e)
{
{
axWindowMediaPlayer1.Ctlcontrols.Stop();
}
//At Pause button (If you want pause button)
private void pause_Btn_click(object sender, EventArgs e)
{
{
axWindowMediaPlayer1.Ctlcontrols.Pause();
}
private void playlist_Btn_click(object sender, EventArgs e)
{
{
OpenFileDialog openfile = new OpenFileDialog ();
openfile .Multiselect = true ;
if(openfile .ShowDialog() ==System.Window.Forms.DialogResult.OK)
{
openfile .Multiselect = true ;
if(openfile .ShowDialog() ==System.Window.Forms.DialogResult.OK)
{
files = openfile .SafeFileNames; //Save only the names
paths = openfile .FileNames; //save the full path
for ( i = 0 ; i < files.Length ; i++)
{
listBox1.Items.Add ( files[ i ]); //Add songs to list box
}
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
{
axWindowMediaPlayer1.URL = paths[listBox1.SelectedIndex];
}
No comments:
Post a Comment