-
March 22nd, 2011, 06:44 AM
#1
[RESOLVED] problem with music playlist
Here is the relevant code.
Code:
Private Sub Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLAdd.Click
OpenFileDialog2.ShowDialog()
Playlist.Items.Add(OpenFileDialog2.FileName)
End Sub
Private Sub Remove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLRemove.Click
Playlist.Items.Remove(Playlist.SelectedItem)
End Sub
Private Sub PLSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLSave.Click
IO.Directory.CreateDirectory("C:\Selector\Playlists")
Dim w As New IO.StreamWriter("C:\Selector\Playlists\test.txt")
Dim i As Integer
For i = 0 To Playlist.Items.Count - 1
w.WriteLine(Playlist.Items.Item(i))
Next
w.Close()
End Sub
Private Sub PLLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLLoad.Click
Dim r As New IO.StreamReader("C:\Selector\Playlists\test.txt")
While (r.Peek() > -1)
Playlist.Items.Add(r.ReadLine)
End While
r.Close()
End Sub
Private Sub PLPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLPlay.Click
Process.Start(Playlist.SelectedItem)
End Sub
I want to allow the user to name their own file for the playlist instead of it being "test.txt".
I want a way to avoid duplicate song files.
I want a way to shorten the file name to exclude the file path. (I'll probably have that figured out on my own)
I want to overwrite one playlist with a loaded one.
Finally, How can I make this symbol, ►, in vb.net? (for my play button)
Last edited by 957; March 22nd, 2011 at 06:50 AM.
Reason: grammar
-
March 22nd, 2011, 01:41 PM
#2
Re: problem with music playlist
You could put an IF STATEMENT inside here, to pop up a message box for each song. Better idea would be to let user save a DIFFERENT name, and keep the filename separate for future use.
-
March 22nd, 2011, 04:15 PM
#3
Re: problem with music playlist
Look at SaveFileDialog. The user can also create directories if needed.
OpenFileDialog.SafeFileName is the file name without the path. I would do what dglienna said and save both.
Dupes? that's up to you. Probably check after the user selects a new file.
Check out SaveFileDialog.OverwritePrompt
-
March 23rd, 2011, 08:39 AM
#4
Re: problem with music playlist
Do I have to import anything to use overwriteprompt?
My code has changed so that there is no longer a file saved to the computer.
Code:
Private Sub Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLAdd.Click
OpenFileDialog2.ShowDialog()
Playlist.Items.Add(OpenFileDialog2.FileName)
End Sub
Private Sub Remove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLRemove.Click
Playlist.Items.Remove(Playlist.SelectedItem)
End Sub
Private Sub PLSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLSave.Click
Playlists.Items.Add(Playlist.Items)
End Sub
Private Sub PLLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLLoad.Click
Playlist.Items.Add(Playlists.Items)
End Sub
Private Sub PLPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLPlay.Click
If OpenFileDialog2.FileName = "" Then
Exit Sub
Else
Process.Start(Playlist.SelectedItem)
End If
End Sub
When I use this code to save a playlist to the second listbox as a single item that can be loaded as the original multiple items to the first listbox, all I get in the second listbox is the word, "(Collection)". Also, from this approach how could I allow the user to name their own playlist?
-
March 23rd, 2011, 09:48 AM
#5
Re: problem with music playlist
How is the user going to "save" their playlist if you don't write it to a file? If there not saving it to a file why would they have to name it? If you use SaveFileDialog it will allow the user to name the file. You will probably want to dictate the extension (like ".PL")
-
March 23rd, 2011, 03:55 PM
#6
Re: problem with music playlist
how do I dictate an extension?
-
March 23rd, 2011, 04:02 PM
#7
Re: problem with music playlist
-
March 23rd, 2011, 04:17 PM
#8
Re: problem with music playlist
They have to name it if they want multiple playlists and be able to identify the contents of each one by it's name.
-
March 24th, 2011, 03:53 PM
#9
Re: problem with music playlist
the main problem is transferring multiple items from one listbox to the other as only one item under a user-designated title like, "Avenged Sevenfold Songs"
-
March 24th, 2011, 10:12 PM
#10
Re: problem with music playlist
ok nvmd I solved all of that and I will post the code after someone tells me how to put this character onto a button, "►"
-
March 25th, 2011, 12:15 AM
#11
Re: problem with music playlist
Found this by searching:
Code:
If isPlay = True Then
If isPaused = False Then
btnPlay.Image = Image.FromFile("iconPause.png")
isPaused = True
isPlay = False
End If
GoTo Endline
End If
If isPlay = False Then
If isPaused = True Then
btnPlay.Image = Image.FromFile("iconPlay.png")
isPaused = False
isPlay = True
End If
End If
http://stackoverflow.com/questions/1...d-pause-button
-
March 25th, 2011, 11:22 AM
#12
Re: problem with music playlist
is there anyway to get it without and icon and only text?
-
March 25th, 2011, 11:52 AM
#13
Re: problem with music playlist
-
March 25th, 2011, 11:05 PM
#14
Re: problem with music playlist
ok here is what I did
Code:
Private Sub PLMusicSN_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLMusicSN.SelectedIndexChanged
PLMusicFP.SelectedIndex = PLMusicSN.SelectedIndex
End Sub
Private Sub PLMAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLMAdd.Click
OpenFileDialog2.ShowDialog()
PLMusicFP.Items.Add(OpenFileDialog2.FileName)
PLMusicSN.Items.Add(OpenFileDialog2.SafeFileName)
End Sub
Private Sub PLMRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLMRemove.Click
PLMusicFP.Items.Remove(PLMusicFP.SelectedItem)
PLMusicSN.Items.Remove(PLMusicSN.SelectedItem)
End Sub
Private Sub PLMSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLMSave.Click
IO.Directory.CreateDirectory("C:\Selector\Playlists")
Dim wFP As New IO.StreamWriter("C:\Selector\Playlists\MusicFP.pl")
Dim i As Integer
For i = 0 To PLMusicFP.Items.Count - 1
wFP.WriteLine(PLMusicFP.Items.Item(i))
Next
Dim wSN As New IO.StreamWriter("C:\Selector\Playlists\MusicSN.pl")
For i = 0 To PLMusicSN.Items.Count - 1
wSN.WriteLine(PLMusicSN.Items.Item(i))
Next
wFP.Close()
wSN.Close()
My.Settings.PLMDir = Me.PLMDirL.Text
My.Settings.Save()
End Sub
Private Sub PLMPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLMPlay.Click
PLMusicSN.SelectedItem = PLMusicFP.SelectedItem
If OpenFileDialog2.FileName = "" Then
Exit Sub
Else
Process.Start(PLMusicFP.SelectedItem)
End If
End Sub
Private Sub PLVideoSN_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLMusicSN.SelectedIndexChanged
PLVideoFP.SelectedIndex = PLVideoSN.SelectedIndex
End Sub
Private Sub PLVAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLVAdd.Click
OpenFileDialog2.ShowDialog()
PLVideoFP.Items.Add(OpenFileDialog2.FileName)
PLVideoSN.Items.Add(OpenFileDialog2.SafeFileName)
End Sub
Private Sub PLVRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLVRemove.Click
PLVideoFP.Items.Remove(PLVideoFP.SelectedItem)
PLVideoSN.Items.Remove(PLVideoSN.SelectedItem)
End Sub
Private Sub PLVSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLVSave.Click
IO.Directory.CreateDirectory("C:\Selector\Playlists")
Dim wFP As New IO.StreamWriter("C:\Selector\Playlists\VideoFP.pl")
Dim i As Integer
For i = 0 To PLVideoFP.Items.Count - 1
wFP.WriteLine(PLVideoFP.Items.Item(i))
Next
Dim wSN As New IO.StreamWriter("C:\Selector\Playlists\VideoSN.pl")
For i = 0 To PLVideoSN.Items.Count - 1
wSN.WriteLine(PLVideoSN.Items.Item(i))
Next
wFP.Close()
wSN.Close()
My.Settings.PLVDir = Me.PLVDirL.Text
My.Settings.Save()
End Sub
Private Sub PLVPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLVPlay.Click
PLVideoSN.SelectedItem = PLVideoFP.SelectedItem
If OpenFileDialog2.FileName = "" Then
Exit Sub
Else
Process.Start(PLVideoFP.SelectedItem)
End If
End Sub
and in forms load
Code:
Me.PLMDirL.Text = My.Settings.PLMDir
Me.PLVDirL.Text = My.Settings.PLVDir
If PLMDirL.Text = "0" Then
IO.Directory.CreateDirectory("C:\Selector\Playlists\")
System.IO.File.Create("c:\Selector\Playlists\MusicFP.pl")
System.IO.File.Create("c:\Selector\Playlists\MusicSN.pl")
PLMDirL.Text = 1
Else
Dim rMFP As New IO.StreamReader("C:\Selector\Playlists\MusicFP.pl")
While (rMFP.Peek() > -1)
PLMusicFP.Items.Add(rMFP.ReadLine)
End While
rMFP.Close()
Dim rMSN As New IO.StreamReader("C:\Selector\Playlists\MusicSN.pl")
While (rMSN.Peek() > -1)
PLMusicSN.Items.Add(rMSN.ReadLine)
End While
rMSN.Close()
Dim rVFP As New IO.StreamReader("C:\Selector\Playlists\VideoFP.pl")
While (rVFP.Peek() > -1)
PLVideoFP.Items.Add(rVFP.ReadLine)
End While
rVFP.Close()
Dim rVSN As New IO.StreamReader("C:\Selector\Playlists\VideoSN.pl")
While (rVSN.Peek() > -1)
PLVideoSN.Items.Add(rVSN.ReadLine)
End While
rVSN.Close()
End If
If PLVDirL.Text = "0" Then
IO.Directory.CreateDirectory("C:\Selector\Playlists\")
System.IO.File.Create("c:\Selector\Playlists\VideoFP.pl")
System.IO.File.Create("c:\Selector\Playlists\VideoSN.pl")
PLVDirL.Text = 1
Else
Dim rVFP As New IO.StreamReader("C:\Selector\Playlists\VideoFP.pl")
While (rVFP.Peek() > -1)
PLVideoFP.Items.Add(rVFP.ReadLine)
End While
rVFP.Close()
Dim rVSN As New IO.StreamReader("C:\Selector\Playlists\VideoSN.pl")
While (rVSN.Peek() > -1)
PLVideoSN.Items.Add(rVSN.ReadLine)
End While
rVSN.Close()
End If
-
March 25th, 2011, 11:18 PM
#15
Re: [RESOLVED] problem with music playlist
Should have used SELECT CASE for peek, to save 90% of the code
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|