|
-
Mar 22nd, 2005, 06:18 PM
#1
Thread Starter
Hyperactive Member
little adjustment required
Hi all,
I have this code which works perfect but I just need help adjusting it slightly.
here is my code
VB Code:
Private Sub Command2_Click()
Dim f1 As Integer, xmlpath As String, songpath As String, mp3path As String, f2 As Integer, i As Integer, pos As Integer
Dim Artist As String, SongName As String, artname As String, fname As String, MyPath As String
Dim mytag As Boolean
mp3path = "C:\Program Files\mgamerz\XML PLAYER\my_mp3s\"
xmlpath = "C:\Program Files\mgamerz\XML PLAYER\"
SongName = Dir(mp3path & "\*.mp3")
fname = mp3path & SongName
With Form4
While Not Len(SongName) = 0
' Artist = GetMP3Tag(fname)
If Not i = 0 Then
Load .Label1(i): Load .Text1(i)
.Label1(i).Top = .Label1(i - 1).Top + 350
.Text1(i).Top = .Text1(i - 1).Top + 350
.Label1(i).Visible = True: .Text1(i).Visible = True
End If
.Label1(i) = SongName
mytag = GetMP3Tag(fname)
.Text1(i) = RTrim(MP3Info.sArtist)
SongName = Dir
fname = mp3path & SongName
i = i + 1
Wend
.Height = .Text1(.Text1.Count - 1).Top + 1600
.TAG = mp3path
MDIForm1.Caption = "Close This Form to Update XML Playlist"
.Show
' .WindowState = 2
End With
TAG = "wait"
While TAG = "wait"
DoEvents
Wend
i = 1
f2 = FreeFile
Open mp3path & "mp3.txt" For Output As #f2
f1 = FreeFile
Open xmlpath & "audiolist.xml" For Output As #f1
Print #f1, "<?xml version=""1.0""?>"
Print #f1, "<songs>"
SongName = Dir(mp3path & "\*.mp3")
i = 1
While Not Len(SongName) = 0
' if you can return the name of the artist you put the code in here
mytag = GetMP3Tag(mp3path & SongName)
'pos = InStr(mytag, "\")
mytag = Replace(mytag, "\", "/")
Do While InStr(mytag, " ")
mytag = Replace(mytag, " ", "")
Loop
Artist = RTrim(MP3Info.sArtist)
If Len(Artist) = 0 Then Artist = "UNKOWN"
MyPath = Right(mp3path, (Len(mp3path) - Len(xmlpath))) & " " & SongName
MyPath = Replace(MyPath, "\", "/")
MyPath = Replace(MyPath, " ", "", 1, 1)
songpath = "<song path=""" & MyPath & """ artist=""" & Artist & """ title=""" & SongName & """/> "
Print #f1, songpath
Print #f2, SongName
Sleep 100
SongName = Dir
Wend
Print #f1, "</songs>"
Close
End Sub
Private Sub Command3_Click()
Dim Q As String
Q = "" & vbCrLf
Q = Q + "Developed By" & vbCrLf
Q = Q + "Rob Gibson, Tony Dockery 2005© " & vbCrLf
MsgBox Q, vbInformation, "XML Updater V2.0"
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Command5_Click()
Dim strFile() As String, strPath As String
Dim n As Long, nCount As Long
On Error Resume Next
With CommonDialog1
.Flags = cdlOFNAllowMultiselect + cdlOFNExplorer
.CancelError = True
.InitDir = "C:\Program Files\mgamerz\XML PLAYER\my_mp3s"
.DialogTitle = "Select File To Delete"
.ShowOpen
If Err.Number <> cdlCancel Then
strFile = Split(.FileName, vbNullChar)
nCount = UBound(strFile)
If nCount = 0 Then
'Only one file is selected so split up the path and the filename
ReDim strFile(1)
strFile(0) = Left$(.FileName, InStrRev(.FileName, "\"))
strFile(1) = Mid$(.FileName, InStrRev(.FileName, "\") + 1)
nCount = 1
End If
strPath = strFile(0)
If Right$(strPath, 1) <> "\" Then
strPath = strPath & "\"
End If
For n = 1 To nCount
Kill strPath & strFile(n)
Next
End If
End With
End Sub
It displays the xml file like so
<?xml version="1.0"?>
<songs>
<song path="my_mp3s/Coldplay - Trouble.mp3" artist="Coldplay" title="Coldplay - Trouble.mp3"/>
</songs>
I would like it to not display the .mp3 in the title like below
<?xml version="1.0"?>
<songs>
<song path="my_mp3s/Coldplay - Trouble.mp3" artist="Coldplay" title="Coldplay - Trouble"/>
</songs>
Sorry to bother you all again
Thanks
Rob
-
Mar 22nd, 2005, 06:34 PM
#2
Re: little adjustment required
Need another variable
VB Code:
dim mysong as string
mysong = left$(songname, len(songname) - 4)
songpath = "<song path=""" & MyPath & """ artist=""" & Artist & """ title=""" & mysong & """/> "
That should do it.
-
Mar 22nd, 2005, 06:54 PM
#3
Thread Starter
Hyperactive Member
Re: little adjustment required
Thanks for replying, I changed my code as below
VB Code:
Private Sub Command2_Click()
Dim f1 As Integer, xmlpath As String, songpath As String, mp3path As String, f2 As Integer, i As Integer, pos As Integer
Dim Artist As String, SongName As String, artname As String, fname As String, MyPath As String
Dim mysong As String
Dim mytag As Boolean
mp3path = "C:\Program Files\mgamerz\XML PLAYER\my_mp3s\"
xmlpath = "C:\Program Files\mgamerz\XML PLAYER\"
SongName = Dir(mp3path & "\*.mp3")
fname = mp3path & SongName
With Form4
While Not Len(SongName) = 0
' Artist = GetMP3Tag(fname)
If Not i = 0 Then
Load .Label1(i): Load .Text1(i)
.Label1(i).Top = .Label1(i - 1).Top + 350
.Text1(i).Top = .Text1(i - 1).Top + 350
.Label1(i).Visible = True: .Text1(i).Visible = True
End If
.Label1(i) = SongName
mytag = GetMP3Tag(fname)
.Text1(i) = RTrim(MP3Info.sArtist)
SongName = Dir
fname = mp3path & SongName
i = i + 1
Wend
.Height = .Text1(.Text1.Count - 1).Top + 1600
.TAG = mp3path
MDIForm1.Caption = "Close This Form to Update XML Playlist"
.Show
' .WindowState = 2
End With
TAG = "wait"
While TAG = "wait"
DoEvents
Wend
i = 1
f2 = FreeFile
Open mp3path & "mp3.txt" For Output As #f2
f1 = FreeFile
Open xmlpath & "audiolist.xml" For Output As #f1
Print #f1, "<?xml version=""1.0""?>"
Print #f1, "<songs>"
SongName = Dir(mp3path & "\*.mp3")
i = 1
While Not Len(SongName) = 0
' if you can return the name of the artist you put the code in here
mytag = GetMP3Tag(mp3path & SongName)
'pos = InStr(mytag, "\")
mytag = Replace(mytag, "\", "/")
Do While InStr(mytag, " ")
mytag = Replace(mytag, " ", "")
Loop
Artist = RTrim(MP3Info.sArtist)
If Len(Artist) = 0 Then Artist = "UNKOWN"
MyPath = Right(mp3path, (Len(mp3path) - Len(xmlpath))) & " " & SongName
MyPath = Replace(MyPath, "\", "/")
MyPath = Replace(MyPath, " ", "", 1, 1)
songpath = "<song path=""" & MyPath & """ artist=""" & Artist & """ title=""" & mysong & """/> "
Print #f1, songpath
Print #f2, SongName
Sleep 100
SongName = Dir
Wend
Print #f1, "</songs>"
Close
End Sub
but the XML is coming out without the title at all as below
<?xml version="1.0"?>
<songs>
<song path="my_mp3s/06 - morricone.mp3" artist="Somebody" title=""/>
<song path="my_mp3s/13 - the flower of carnage.mp3" artist="Somebody Else" title=""/>
<song path="my_mp3s/Bluetones - Marblehead Johnson - Cd Singles.mp3" artist="Bluetones" title=""/>
<song path="my_mp3s/haven - Till The End.mp3" artist="Haven" title=""/>
<song path="my_mp3s/Inspiral Carpets - She Comes In The Fall.mp3" artist="Inspiral Carpets" title=""/>
<song path="my_mp3s/Say something.mp3" artist="Haven" title=""/>
</songs>
but I wanted the title but without the .mp3
thanks
R
-
Mar 22nd, 2005, 06:59 PM
#4
Re: little adjustment required
right above the line that you changed, you have to have the mysong = left(...
the dim goes elsewhere. that's why it didn't work
VB Code:
' add line here
songpath = "<song path=""" & MyPath & """ artist=""" & Artist & """ title=""" & mysong & """/
> "
-
Mar 22nd, 2005, 07:07 PM
#5
Thread Starter
Hyperactive Member
Re: little adjustment required
Thanks very much (AGAIN)
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
|