Results 1 to 17 of 17

Thread: Can anybody think of possible solution [RESOLVED]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    277

    Resolved Can anybody think of possible solution [RESOLVED]

    Hi I have been trying different things all day today to try and extract the artist from an mp3 file and add it to my xml playlist anyone got anyy ideas as I just don't know how to get round this

    Cheers
    Rob
    Last edited by robvr6; Jan 20th, 2005 at 08:19 AM.

  2. #2
    Lively Member Tw1sted L0gic's Avatar
    Join Date
    Jan 2005
    Posts
    88

    Re: Can anybody think of possible solution

    I once stumpled upon an MP3 class module that makes reading MP3 info a doddle.
    It may have been on Planetsourcecode.com
    Naughty but Nice

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    277

    Re: Can anybody think of possible solution

    Thanks what it is I have a flash mp3 player that reads from an xml file but at current it will only write the path like this

    <?xml version="1.0"?>
    <songs>
    <song path="C:\Program Files\mgamerz\my_mp3s\" title=".mp3"/>
    </songs>

    and I need this to include the artist also

    <?xml version="1.0"?>
    <songs>
    <song path="C:\Program Files\mgamerz\my_mp3s\" artist="" title=""/>
    </songs>


    Does this sound similar

  4. #4
    Lively Member Misspell's Avatar
    Join Date
    Mar 2002
    Location
    Located
    Posts
    69

    Re: Can anybody think of possible solution

    Not sure if this will work for you or be efficient for your needs, but you could make a playlist in winamp and then phase through the play list file.

    Quote Originally Posted by WinAmp Playlist File
    #EXTM3U
    #EXTINF:113,Pounded Clown - Pounded Clown - Pounded Clown
    Can Of Pork\01 - Pounded Clown - Pounded Clown - Bad Trip.mp3

    #EXTINF:99,Brent's TV - Brent's TV - Brent's TV / Trin
    Can Of Pork\02 - Brent's TV - Brent's TV - Trinidad.mp3
    Or maybe this will help...
    http://www.Planet-Source-Code.com/vb...52400&lngWId=1


    _

    ~ What was once an opinion, became a fact, to be later proven wrong... ~

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Can anybody think of possible solution

    Maybe this article will help.

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

    Re: Can anybody think of possible solution

    I wouldn't include the info in the filename. Make it a separate field in the XML file. Just include more tags.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    277

    Re: Can anybody think of possible solution

    I need to generate a name from somwhere If you know what I mean. This is what I am unsure about.

    I can get it like this

    ?xml version="1.0"?>

    <songs>
    <song path="C:\Program Files\mgamerz\my_mp3s\" title=".mp3"/>
    </songs>


    but really
    I need this
    ?xml version="1.0"?>

    <songs>
    <song path="C:\Program Files\mgamerz\my_mp3s\" artist="" title=""/>

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

    Re: Can anybody think of possible solution

    ?xml version="1.0"?>

    <songs>
    <song path="C:\Program Files\mgamerz\my_mp3s\" artist="" title=""/>

    should be something like this:

    Code:
    ?xml version="1.0"?>
    
    <songs>
        <song path>C:\Program Files\mgamerz\my_mp3s\</song path>
        <artist> My Artist </artist>
        <title>  My Title </title>
    </songs>
    Forget freehand. Here is an actual example that you can paste into an html document and open.

    Code:
    <XML ID="file1">
       <COLLECTION xmlns:dt="urn:schemas-microsoft-com:datatypes">
         <DATE dt:dt="datetime">1998-10-13T15:56:00</DATE>
         <BOOK>
           <TITLE>Lover Birds</TITLE>
           <AUTHOR>Cynthia Randall</AUTHOR>
           <PUBLISHER>Lucerne Publishing</PUBLISHER>
        </BOOK>
        <BOOK>
           <TITLE>The Sundered Grail</TITLE>
           <AUTHOR>Eva Corets</AUTHOR>
           <PUBLISHER>Lucerne Publishing</PUBLISHER>
        </BOOK>
       </COLLECTION>
    </XML>
    <XML ID="file2">
       <COLLECTION>
        <BOOK>
           <TITLE>Inside MSXML</TITLE>
           <AUTHOR>Microsoft</AUTHOR>
           <PUBLISHER>The MS Press</PUBLISHER>
        </BOOK>
        <BOOK>
           <TITLE>Splish Splash</TITLE>
           <AUTHOR>Paula Thurman</AUTHOR>
           <PUBLISHER>Scootney</PUBLISHER>
        </BOOK>
       </COLLECTION>
    </XML>
    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <TITLE></TITLE>
    </HEAD>
    <script language="vbscript" id="mergeFunction">
    Dim xmldoc
    Dim xmldoc2
    
    ' First document.
    Set xmldoc = file1.XMLDocument
    ' Second document.
    Set xmldoc2 = file2.XMLDocument
    
    Function merge_xml()
       Dim iIndex
       Dim xmlNode
       Dim NodeList
       
       Set NodeList = xmldoc2.selectNodes("*/BOOK")
       ' Merge.
       
       For iIndex = 0 To NodeList.length - 1
          Set xmlNode = NodeList.Item(iIndex).cloneNode(True)
          xmldoc.documentElement.appendChild xmlNode
       Next
    End Function
    </script>
    <script language="vbscript">
    Function mergeAndShow()
       merge_xml()
       showDoc(1)
       Showfile1.value="Show Merged File"
    End Function
    
    Function showDoc(iIndex)
       select case iIndex
          case 1 GeneralDisplayBox.value=xmldoc.xml
          case 2 GeneralDisplayBox.value=xmldoc2.xml
          case Else GeneralDisplayBox.value=""
       End select
       
    End Function
    </script>
    <BODY>
    <PRE>
    <script language="vbscript">
       document.writeln document.scripts.item("mergefunction").text
    </script>
    </PRE>
    <TABLE border='2'>
       <TR>
          <TD>
             <TEXTAREA title='General Display' id='GeneralDisplayBox' rows='20' cols='60' readonly></TEXTAREA>
          </TD>
          <TD width='90'>
             <TABLE>
                <TR align=center>
                   <TD>
                      <input id='Showfile1' type='button' value="Show File1" onclick="showDoc(1)" />
                   </TD>
                </TR>
                <TR align=center>
                   <TD>
                      <input type='button' value="Show File2" onclick="showDoc(2)" />
                   </TD>
                </TR>
                <TR align=center>
                   <TD>
                      <input type='button' value="MergeFiles" onclick="mergeAndShow()"/>
                   </TD>
                </TR>
             </TABLE>
          </TD>
       </TR>
    </TABLE>
    <P>&nbsp;</P>
    </BODY>
    </HTML>
    paste it into EDIT and save it as html, and then open it to see a merge application. it's from the sdk.

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    277

    Re: Can anybody think of possible solution

    I need it to update from my vb app when a command button is clicked. OThats how it works now. will it do the same?

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

    Re: Can anybody think of possible solution

    the example just merges two files.

    You can have the program update but you will have to change it to match the new XML that you use. It woud be better not to combine things, though.

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    277

    Re: Can anybody think of possible solution

    Sorry again but will that find the artist from the mp3 file or will that have to be edited by hand? sorry I'm a bit confused

    Rob

  12. #12
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Can anybody think of possible solution

    I've already posted a link to an article with source code that show you how to read this information from a mp3 file.

  13. #13
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Can anybody think of possible solution

    i have put together some code that will read the artist from the mp3, if the artist is not listed in the mp3 allows you to enter the artist name and it will be saved into the mp3

    this works on a ntfs file system, but i am really unsure if it will also work on fat file system, as from what i have read it reads the headers differently.

    pete

  14. #14
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Can anybody think of possible solution

    The Use Of This Code, Will Modify Your Mp3 Files, Until It Is Fully Tested, You Should Use It Only With Copies Of Your Mp3s.
    Attached Files Attached Files

  15. #15
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Can anybody think of possible solution

    THE USE OF THIS CODE, WILL MODIFY YOUR MP3 FILES, UNTIL IT IS FULLY TESTED, YOU SHOULD USE IT ONLY WITH COPIES OF YOUR MP3S.

    i did not write the code in the module that writes to the mp3s, modified it a bit and it seems to work ok on ntfs file system.
    the credit for that code is in the module.

    for this to work in your project you need to add the form and module attached.
    you need to add a mdiform, mdiform1
    and update your sub including to dim any new variables

    VB Code:
    1. Dim f1 As Integer, songpath As String, mp3path As String, f2 As Integer, i As Integer
    2.     Dim Artist As String, SongName As String, artname As String, fname As String
    3.     Dim mytag As Boolean
    4.     mp3path = "C:\Documents and Settings\User1\My Documents\My Music\MP3\The Greatest Oldies (vol 1)\"
    5.      
    6.      SongName = Dir(mp3path & "\*.mp3")
    7.      fname = mp3path & SongName
    8.      
    9.             With Form4
    10.    
    11.     While Not Len(SongName) = 0
    12.        
    13. '        Artist = GetMP3Tag(fname)
    14.                 If Not i = 0 Then
    15.                     Load .Label1(i): Load .Text1(i)
    16.                     .Label1(i).Top = .Label1(i - 1).Top + 350
    17.                     .Text1(i).Top = .Text1(i - 1).Top + 350
    18.                     .Label1(i).Visible = True: .Text1(i).Visible = True
    19.                    
    20.                 End If
    21.                
    22.                 .Label1(i) = SongName
    23.                 mytag = GetMP3Tag(fname)
    24.                 .Text1(i) = RTrim(MP3Info.sArtist)
    25.                      
    26.  
    27.         SongName = Dir
    28.              fname = mp3path & SongName
    29.  
    30.         i = i + 1
    31.    
    32.     Wend
    33.                 .Height = .Text1(.Text1.Count - 1).Top + 1600
    34.                 .TAG = mp3path
    35.                 MDIForm1.Caption = "You must close this form before continuing"
    36.                 .Show
    37. '                .WindowState = 2
    38.             End With
    39.    
    40.      
    41.    i = 1
    42.      f2 = FreeFile
    43.     Open mp3path & "mp3.txt" For Output As #f2
    44.      f1 = FreeFile
    45.      
    46.     Open mp3path & "audiolist.xml" For Output As #f1
    47.     Print #f1, "<?xml version=""1.0""?>"
    48.     Print #f1, "<songs>"
    49.     SongName = Dir(mp3path & "\*.mp3")
    50.     i = 1
    51.     While Not Len(SongName) = 0
    52.        
    53.         ' if you can return the name of the artist you put the code in here
    54.  
    55.                 mytag = GetMP3Tag(mp3path & SongName)
    56.                 Artist = RTrim(MP3Info.sArtist)
    57.                  if Len(Artist) = 0 Then Artist  = "UNKOWN"
    58.         songpath = "<song path=""" & mp3path & SongName & """ artist=""" & Artist & """ title=""" & SongName & """/> "
    59.         Print #f1, songpath
    60.         Print #f2, SongName
    61.         Sleep 100
    62.         SongName = Dir
    63.    
    64.     Wend
    65.  
    66.     Print #f1, "</songs>"
    67. Close

    this will now return artist names in mp3 files if they are recorded or allow the user to input the artist names for the blanks and save them into the mp3, which will then be read again to put into the playlist.

    TRY IT

    pete
    Attached Files Attached Files
    Last edited by westconn1; Jan 19th, 2005 at 03:31 AM. Reason: i can't see the attchment some one will have tell me where i went wrong

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    277

    Re: Can anybody think of possible solution

    Thats Brilliant - Amazed once again Thanks.

    Just a quickie with the original file it puts the audiolist. in the main directory i.e program files\mgamerz\

    but now it goes to program files\mgamerz\my_mp3s

    I know it is probably something blindingly obvious that I've not done. Also you know if I didn't use a mdi form would the artist just return as unknown.

    Thanks again
    Rob

  17. #17
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Can anybody think of possible solution

    if you don't add the mdi form i am sure you will just get errors and would not complete, the mdi form is need to hold form4
    just go to project, add MDIform

    if you want the playlist to go to a different folder to where the mp3s are you will need to change the line
    open whatever & "audiolist.xml" for output...................

    and put in your filepath instead of whatever is there now

    pete

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