1 Attachment(s)
Re: serialization question
i have attached a screen shot of the playlist form. Hope it helps explain my problem
1 Attachment(s)
Re: serialization question
Quote:
Originally Posted by
beginner91
i have attached a screen shot of the playlist form. Hope it helps explain my problem
It is better to submit image files as jpegs or gifs, as not everyone can read docX files. For the benefit of those of us who either don't have an up-to-date Word, or don't know that docX files are effectively zip files :), here is the relevant image:
Re: serialization question
Quote:
or don't know that docX files are effectively zip file
...?
Re: serialization question
Quote:
Originally Posted by
BioPhysEngr
...?
It's true - change the extension to .zip and you can open it using unzip or some such application. That's how I extracted the image.
Re: serialization question
Re: serialization question
now that the image is sorted can someone help with my problem?
Re: serialization question
As far as I know there's no VS standard library containing Playlist. Mind givings us what you do in your add() method ?
Re: serialization question
ok here is all the code for you get a better idea of what i'm trying to do
Code:
namespace Playing_MP3_songs
{
public partial class CreatePlaylistForm : Form
{
[DllImport("winmm.dll")]
private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback);
bool paused = false;
ArrayList myPlaylistsCollection = new ArrayList();
public CreatePlaylistForm()
{
InitializeComponent();
// DirectoryInfo dinfo = new DirectoryInfo(@"C:\Users\Public\Music\Sample Music");
DirectoryInfo dinfo = new DirectoryInfo(@"C:\music");
FileInfo[] Files = dinfo.GetFiles("*.mp3");
foreach (FileInfo file in Files)
{
LibraryTracks.Items.Add(file.Name);
}
}
private void button2_Click(object sender, EventArgs e) //add track
{
foreach(string name in PlaylistTracks.Items )
{
if (LibraryTracks.SelectedItem.ToString() == name)
{
MessageBox.Show("Song already in playlist");
return;
}
}
PlaylistTracks.Items.Add(LibraryTracks.SelectedItem);
}
private void button3_Click(object sender, EventArgs e) //remove track
{
PlaylistTracks.Items.Remove(PlaylistTracks.SelectedItem);
}
private void button1_Click(object sender, EventArgs e) //create playlist
{
Playlist temp = new Playlist(textBoxPlaylist.Text);
foreach(string name in PlaylistTracks.Items)
{
temp.addSong(name);
}
}
}
}
and looking at the image of what form the first listbox is populated from a folder called music. The second listbox is for the playlist. The add/remove buttons add or remove the songs to the second listbox. I want the create button to save the selection of songs in the second listbox and the name in the textbox.
I then have another form where I want the names of the playlists to be displayed in
Re: serialization question
Look at this code:
Code:
private void button1_Click(object sender, EventArgs e) //create playlist
{
Playlist temp = new Playlist(textBoxPlaylist.Text);
foreach(string name in PlaylistTracks.Items)
{
temp.addSong(name);
}
}
You are creating a new Playlist and populating it correctly, but it is lost when the click handler finishes. You need to save it in a variable (i.e. a collection of playlists) outside this function.
Re: serialization question
ok thanks but how would I do that?
Re: serialization question
Quote:
Originally Posted by
beginner91
ok thanks but how would I do that?
Instead of having the Playlist temp a local variable inside the button click handler, make it a class field or property (so it has class scope).
Do you know how to declare a class field? E.g.
Code:
private PlayList _playList;
Re: serialization question
i ready made a class for playlist
Code:
namespace Playing_MP3_songs
{
class Playlist
{
private string name;
ArrayList list;
public Playlist(string name)
{
this.name = name;
list = new ArrayList();
}
public void addSong(string fileName)
{
list.Add(fileName);
}
}
}
Playlist is referring to this class
Re: serialization question
You have this data member in your class:
Code:
ArrayList myPlaylistsCollection = new ArrayList();
Shouldn't the playlists go in there :confused:
Re: serialization question
yes you are right. so how do i put the playlists in there?