Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
I want to create a small windows application, which is playing mpe files one by one continuously. I can add many mp3 files and play one by one by clicking each files. But actually I want automatically it should jump into next song.
 

So can any one help me?
 

Thanks in @dv@nce......:P
Posted 25-Jun-13 0:25am
Comments
Nelek at 25-Jun-13 5:57am
   
Yes, there are a lot of very capable people here in CP who can help you. But you didn't describe any problem. Please read What have you tried?[^] so you can understand what I am telling
MuhammadUsman1 at 25-Jun-13 6:19am
   
You can do it easily but as Nelek said What have you tried? so for
Aboobakkar Siddeq D.U at 25-Jun-13 6:36am
   
Yeah I tried many times. Still i'm trying that one. But i'm not getting anything about that. Actually I want to play song continuously one by one, without stop, without pressing any button or any files. So can you help me?
Aboobakkar Siddeq D.U at 25-Jun-13 6:37am
   
THIS IS MY CODE HERE I CAN PLAY SONG DIRECTLY BUT IT WILL PLAY ONLY ONE SONG AND STOP THERE I WANT TO PLAY 2ND SONG WITHOUT PRESSING ANY BUTTON OR FILES
 

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;
using System.IO;
 
namespace Mp3Player
{
public partial class frmMp3Player : Form
{
bool _IsAddFiles = false;
string[] files, paths;
 
public frmMp3Player()
{
InitializeComponent();
}
 
private void btnPlay_Click(object sender, EventArgs e)
{
_IsAddFiles = false;
OpenFileDialog opd = new OpenFileDialog();
opd.Multiselect = true;
 
if (opd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
files = opd.SafeFileNames;
paths = opd.FileNames;
for (int i = 0; i < files.Length; i++)
{
listBox1.Items.Add(files[i]);
}
}
}
 
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (_IsAddFiles.Equals(false))
{
int index = int.Parse(listBox1.SelectedIndex.ToString());
axWindowsMediaPlayer1.URL = paths[index];
}
else
{
string fileName = listBox1.SelectedItem.ToString();
axWindowsMediaPlayer1.URL = @"D:\Mp3Files\" + fileName;
}
}
 
private void btnAdd_Click(object sender, EventArgs e)
{
_IsAddFiles = true;
string file1=string.Empty;
DirectoryInfo directory = new DirectoryInfo(@"D:\Mp3Files");
FileInfo[] files = directory.GetFiles("*.mp3");
foreach (FileInfo file in files)
{
file1 = file.Name;
listBox1.Items.Add(file1);
}
}
 
private void frmMp3Player_Load(object sender, EventArgs e)
{
//if (axWindowsMediaPlayer1.playState != WMPLib.WMPPlayState.wmppsPlaying)
 
LoadSongs();
if (listBox1.Items.Count != 0)
{
for (int i = 0; i < listBox1.Items.Count; i++)
{
listBox1.SelectedIndex = i;
break;
}
}
}
 
public void LoadSongs()
{
_IsAddFiles = true;
string file1 = string.Empty;
DirectoryInfo directory = new DirectoryInfo(@"D:\Mp3Files");
FileInfo[] files = directory.GetFiles("*.mp3");
 
foreach (FileInfo file in files)
{
file1 = file.Name;
listBox1.Items.Add(file1);
}
}
}
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 495
1 Maciej Los 340
2 Richard MacCutchan 265
3 BillWoodruff 225
4 Mathew Soji 200
0 OriginalGriff 8,804
1 Sergey Alexandrovich Kryukov 7,457
2 DamithSL 5,689
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411028.1 | Last Updated 25 Jun 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100