Results 1 to 5 of 5

Thread: little adjustment required

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    277

    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:
    1. Private Sub Command2_Click()
    2. Dim f1 As Integer, xmlpath As String, songpath As String, mp3path As String, f2 As Integer, i As Integer, pos As Integer
    3.     Dim Artist As String, SongName As String, artname As String, fname As String, MyPath As String
    4.  
    5.     Dim mytag As Boolean
    6.    mp3path = "C:\Program Files\mgamerz\XML PLAYER\my_mp3s\"
    7.    xmlpath = "C:\Program Files\mgamerz\XML PLAYER\"
    8.  
    9.  
    10.      
    11.      SongName = Dir(mp3path & "\*.mp3")
    12.      fname = mp3path & SongName
    13.      
    14.             With Form4
    15.    
    16.     While Not Len(SongName) = 0
    17.        
    18. '        Artist = GetMP3Tag(fname)
    19.                 If Not i = 0 Then
    20.                     Load .Label1(i): Load .Text1(i)
    21.                     .Label1(i).Top = .Label1(i - 1).Top + 350
    22.                     .Text1(i).Top = .Text1(i - 1).Top + 350
    23.                     .Label1(i).Visible = True: .Text1(i).Visible = True
    24.                    
    25.                 End If
    26.                
    27.                 .Label1(i) = SongName
    28.                 mytag = GetMP3Tag(fname)
    29.                 .Text1(i) = RTrim(MP3Info.sArtist)
    30.                      
    31.  
    32.         SongName = Dir
    33.              fname = mp3path & SongName
    34.  
    35.         i = i + 1
    36.    
    37.     Wend
    38.                 .Height = .Text1(.Text1.Count - 1).Top + 1600
    39.                 .TAG = mp3path
    40.                 MDIForm1.Caption = "Close This Form to Update XML Playlist"
    41.                 .Show
    42. '                .WindowState = 2
    43.             End With
    44.     TAG = "wait"
    45.     While TAG = "wait"
    46.     DoEvents
    47.     Wend
    48.    
    49.      
    50.    i = 1
    51.      f2 = FreeFile
    52.     Open mp3path & "mp3.txt" For Output As #f2
    53.      f1 = FreeFile
    54.      
    55.     Open xmlpath & "audiolist.xml" For Output As #f1
    56.    
    57.    
    58.     Print #f1, "<?xml version=""1.0""?>"
    59.     Print #f1, "<songs>"
    60.     SongName = Dir(mp3path & "\*.mp3")
    61.     i = 1
    62.     While Not Len(SongName) = 0
    63.        
    64.         ' if you can return the name of the artist you put the code in here
    65.  
    66.                mytag = GetMP3Tag(mp3path & SongName)
    67.              'pos = InStr(mytag, "\")
    68.              mytag = Replace(mytag, "\", "/")
    69. Do While InStr(mytag, " ")
    70.   mytag = Replace(mytag, " ", "")
    71. Loop
    72.  
    73.              Artist = RTrim(MP3Info.sArtist)
    74.              If Len(Artist) = 0 Then Artist = "UNKOWN"
    75.                  
    76.                  
    77.               MyPath = Right(mp3path, (Len(mp3path) - Len(xmlpath))) & " " & SongName
    78.        
    79.              MyPath = Replace(MyPath, "\", "/")
    80.              
    81.  
    82.            MyPath = Replace(MyPath, " ", "", 1, 1)
    83.        songpath = "<song path=""" & MyPath & """ artist=""" & Artist & """ title=""" & SongName & """/> "
    84.        
    85.         Print #f1, songpath
    86.         Print #f2, SongName
    87.         Sleep 100
    88.         SongName = Dir
    89.    
    90.     Wend
    91.  
    92.     Print #f1, "</songs>"
    93. Close
    94.  
    95. End Sub
    96.  
    97. Private Sub Command3_Click()
    98.  
    99. Dim Q As String
    100. Q = "" & vbCrLf
    101. Q = Q + "Developed By" & vbCrLf
    102. Q = Q + "Rob Gibson, Tony Dockery 2005© " & vbCrLf
    103.  
    104.  
    105.  
    106. MsgBox Q, vbInformation, "XML Updater V2.0"
    107.  
    108. End Sub
    109.  
    110.  
    111. Private Sub Command4_Click()
    112. End
    113. End Sub
    114.  
    115. Private Sub Command5_Click()
    116.  
    117. Dim strFile() As String, strPath As String
    118.     Dim n As Long, nCount As Long
    119.     On Error Resume Next
    120.     With CommonDialog1
    121.    
    122.         .Flags = cdlOFNAllowMultiselect + cdlOFNExplorer
    123.         .CancelError = True
    124.         .InitDir = "C:\Program Files\mgamerz\XML PLAYER\my_mp3s"
    125.         .DialogTitle = "Select File To Delete"
    126.                                                              
    127.        .ShowOpen
    128.         If Err.Number <> cdlCancel Then
    129.             strFile = Split(.FileName, vbNullChar)
    130.             nCount = UBound(strFile)
    131.             If nCount = 0 Then
    132.                 'Only one file is selected so split up the path and the filename
    133.                 ReDim strFile(1)
    134.                 strFile(0) = Left$(.FileName, InStrRev(.FileName, "\"))
    135.                 strFile(1) = Mid$(.FileName, InStrRev(.FileName, "\") + 1)
    136.                 nCount = 1
    137.             End If
    138.             strPath = strFile(0)
    139.             If Right$(strPath, 1) <> "\" Then
    140.                 strPath = strPath & "\"
    141.             End If
    142.             For n = 1 To nCount
    143.                     Kill strPath & strFile(n)
    144.            
    145.             Next
    146.         End If
    147.     End With
    148. 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

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: little adjustment required

    Need another variable

    VB Code:
    1. dim mysong as string
    2. mysong = left$(songname, len(songname) - 4)
    3.  songpath = "<song path=""" & MyPath & """ artist=""" & Artist & """ title=""" & mysong & """/> "

    That should do it.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    277

    Re: little adjustment required

    Thanks for replying, I changed my code as below

    VB Code:
    1. Private Sub Command2_Click()
    2. Dim f1 As Integer, xmlpath As String, songpath As String, mp3path As String, f2 As Integer, i As Integer, pos As Integer
    3.     Dim Artist As String, SongName As String, artname As String, fname As String, MyPath As String
    4. Dim mysong As String
    5.  
    6.     Dim mytag As Boolean
    7.    mp3path = "C:\Program Files\mgamerz\XML PLAYER\my_mp3s\"
    8.    xmlpath = "C:\Program Files\mgamerz\XML PLAYER\"
    9.  
    10.  
    11.      
    12.      SongName = Dir(mp3path & "\*.mp3")
    13.      fname = mp3path & SongName
    14.      
    15.             With Form4
    16.    
    17.     While Not Len(SongName) = 0
    18.        
    19. '        Artist = GetMP3Tag(fname)
    20.                 If Not i = 0 Then
    21.                     Load .Label1(i): Load .Text1(i)
    22.                     .Label1(i).Top = .Label1(i - 1).Top + 350
    23.                     .Text1(i).Top = .Text1(i - 1).Top + 350
    24.                     .Label1(i).Visible = True: .Text1(i).Visible = True
    25.                    
    26.                 End If
    27.                
    28.                 .Label1(i) = SongName
    29.                 mytag = GetMP3Tag(fname)
    30.                 .Text1(i) = RTrim(MP3Info.sArtist)
    31.                      
    32.  
    33.         SongName = Dir
    34.              fname = mp3path & SongName
    35.  
    36.         i = i + 1
    37.    
    38.     Wend
    39.                 .Height = .Text1(.Text1.Count - 1).Top + 1600
    40.                 .TAG = mp3path
    41.                 MDIForm1.Caption = "Close This Form to Update XML Playlist"
    42.                 .Show
    43. '                .WindowState = 2
    44.             End With
    45.     TAG = "wait"
    46.     While TAG = "wait"
    47.     DoEvents
    48.     Wend
    49.    
    50.      
    51.    i = 1
    52.      f2 = FreeFile
    53.     Open mp3path & "mp3.txt" For Output As #f2
    54.      f1 = FreeFile
    55.      
    56.     Open xmlpath & "audiolist.xml" For Output As #f1
    57.    
    58.    
    59.     Print #f1, "<?xml version=""1.0""?>"
    60.     Print #f1, "<songs>"
    61.     SongName = Dir(mp3path & "\*.mp3")
    62.     i = 1
    63.     While Not Len(SongName) = 0
    64.        
    65.         ' if you can return the name of the artist you put the code in here
    66.  
    67.                mytag = GetMP3Tag(mp3path & SongName)
    68.              'pos = InStr(mytag, "\")
    69.              mytag = Replace(mytag, "\", "/")
    70. Do While InStr(mytag, " ")
    71.   mytag = Replace(mytag, " ", "")
    72. Loop
    73.  
    74.              Artist = RTrim(MP3Info.sArtist)
    75.              If Len(Artist) = 0 Then Artist = "UNKOWN"
    76.                  
    77.                  
    78.               MyPath = Right(mp3path, (Len(mp3path) - Len(xmlpath))) & " " & SongName
    79.        
    80.              MyPath = Replace(MyPath, "\", "/")
    81.              
    82.  
    83.            MyPath = Replace(MyPath, " ", "", 1, 1)
    84.        songpath = "<song path=""" & MyPath & """ artist=""" & Artist & """ title=""" & mysong & """/> "
    85.        
    86.         Print #f1, songpath
    87.         Print #f2, SongName
    88.         Sleep 100
    89.         SongName = Dir
    90.    
    91.     Wend
    92.  
    93.     Print #f1, "</songs>"
    94. Close
    95.  
    96. 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

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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:
    1. ' add line here
    2.  songpath = "<song path=""" & MyPath & """ artist=""" & Artist & """ title=""" & mysong & """/
    > "

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    277

    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
  •  



Click Here to Expand Forum to Full Width