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; } }
-
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; } }
There can be many reasons for that, first one being that the player is initialized with only 3 tracks, or can run only three — i.e. filtered results. What is your playlist size? That controls how many tracks to play. Using the Windows Media Player Control with Microsoft Visual Studio (Windows)[^]
The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~
-
There can be many reasons for that, first one being that the player is initialized with only 3 tracks, or can run only three — i.e. filtered results. What is your playlist size? That controls how many tracks to play. Using the Windows Media Player Control with Microsoft Visual Studio (Windows)[^]
The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~
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!!!
-
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!!!
Can you try and pass the songs, instead of passing the songs playlist to see if that works.
The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~
-
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; } }
Are you using a trial version of a library with a hard (trial) limit? Seen this sort of behaviour before, along with only playing the first few seconds of a track
C# has already designed away most of the tedium of C++.