Jan 18th, 2005, 01:44 PM
#1
Thread Starter
Hyperactive Member
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 .
Jan 18th, 2005, 02:00 PM
#2
Lively Member
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
Jan 18th, 2005, 02:05 PM
#3
Thread Starter
Hyperactive Member
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
Jan 18th, 2005, 02:30 PM
#4
Lively Member
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.
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... ~
Jan 18th, 2005, 07:50 PM
#5
Re: Can anybody think of possible solution
Maybe this article will help.
Jan 18th, 2005, 08:02 PM
#6
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.
Jan 18th, 2005, 08:12 PM
#7
Thread Starter
Hyperactive Member
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=""/>
Jan 18th, 2005, 08:21 PM
#8
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> </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.
Jan 18th, 2005, 08:31 PM
#9
Thread Starter
Hyperactive Member
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?
Jan 18th, 2005, 08:33 PM
#10
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.
Jan 18th, 2005, 09:09 PM
#11
Thread Starter
Hyperactive Member
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
Jan 18th, 2005, 09:18 PM
#12
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.
Jan 18th, 2005, 11:35 PM
#13
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
Jan 19th, 2005, 03:11 AM
#14
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
Jan 19th, 2005, 03:26 AM
#15
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:
Dim f1 As Integer, songpath As String, mp3path As String, f2 As Integer, i As Integer
Dim Artist As String, SongName As String, artname As String, fname As String
Dim mytag As Boolean
mp3path = "C:\Documents and Settings\User1\My Documents\My Music\MP3\The Greatest Oldies (vol 1)\"
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 = "You must close this form before continuing"
.Show
' .WindowState = 2
End With
i = 1
f2 = FreeFile
Open mp3path & "mp3.txt" For Output As #f2
f1 = FreeFile
Open mp3path & "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)
Artist = RTrim(MP3Info.sArtist)
if Len(Artist) = 0 Then Artist = "UNKOWN"
songpath = "<song path=""" & mp3path & SongName & """ artist=""" & Artist & """ title=""" & SongName & """/> "
Print #f1, songpath
Print #f2, SongName
Sleep 100
SongName = Dir
Wend
Print #f1, "</songs>"
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
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
Jan 19th, 2005, 10:08 AM
#16
Thread Starter
Hyperactive Member
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
Jan 19th, 2005, 10:23 AM
#17
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
Forum Rules
Click Here to Expand Forum to Full Width