Thanks Afzaal Ahmad Zeeshan! my playlist size is more than 3 (often 10). and I user WMPLib. I'm trying to find out the problem but still not find!!!
ngogiatuong
Posts
-
Windows Media Player - Play MP3. -
Windows Media Player - Play MP3.Dear all I create a method to play mp3 base on Text input. I create a playlist and import it to player. but the problem is that, the player plays only 3 files. (and i debugged and found that attributeCount always=3). Please help for this case. Below is my code:
private void PlayMP3()
{
try
{
string strLP = this.textBox1.Text.Trim();
string strPath = Application.StartupPath;
WMPLib.WindowsMediaPlayer player = new WMPLib.WindowsMediaPlayer();
WMPLib.IWMPPlaylist myplaylist = player.playlistCollection.newPlaylist("myplaylist");
//Clear playlist before create new one.
myplaylist.clear();
//Create new playlist
foreach (char c in strLP)
{
//read
string strFileName = "raw\\" + string.Concat(c, ".mp3");
string strFileLocation = Path.Combine(strPath, strFileName);
WMPLib.IWMPMedia media = player.newMedia(strFileLocation);
myplaylist.appendItem(media);
}
player.playlistCollection.importPlaylist(myplaylist);
player.currentPlaylist = myplaylist;
//Play
player.controls.play();} catch (Exception ex) { throw ex; } }