 |
|
 |
the demo is not working, but the article is good and useful
|
|
|
|
 |
|
|
 |
|
 |
Some of the music in my collection has various artists listed.
My whole collection has been tagged with WMP which tags multiple items with a ; so in WMP
Cover to Cover's Composer is "George;Neal Morse;Portnoy"
If I look at the same file in Explorer it shows the composer as "George"
Does anyone know a way of getting the list of composers via shell32? I know I could go to a real mp3 reader, but this seems easier.
|
|
|
|
 |
|
 |
Change your ShellID3TagReader.cs file to this:
using System;
namespace Renamer
{
public struct ShellID3TagReader
{
public static MP3File ReadID3Tags(string FileFullPath){
MP3File mp3File = new MP3File();
string fileName = FileFullPath.Substring(FileFullPath.LastIndexOf("\\")+1);
//parse file path
string filePath = FileFullPath.Substring(0,FileFullPath.LastIndexOf("\\"));
//create shell instance
Shell32.Shell shell = new Shell32.ShellClass();
//set the namespace to file path
Shell32.Folder folder = shell.NameSpace(filePath);
//get ahandle to the file
Shell32.FolderItem folderItem = folder.ParseName(fileName);
//did we get a handle ?
if (folderItem !=null){
mp3File.FileName = fileName;
//query information from shell regarding file
int art = Environment.OSVersion.Version.Major < 6 ? 9 : 13;
int alb = Environment.OSVersion.Version.Major < 6 ? 17 : 14;
int song = Environment.OSVersion.Version.Major < 6 ? 10 : 21;
int trk = Environment.OSVersion.Version.Major < 6 ? 19 : 26;
mp3File.ArtistName = folder.GetDetailsOf(folderItem,art);
mp3File.AlbumName = folder.GetDetailsOf(folderItem,alb);
mp3File.SongTitle = folder.GetDetailsOf(folderItem,song);
try
{
mp3File.TrackNumber = Int32.Parse(folder.GetDetailsOf(folderItem, trk));
}
catch { }
}
//clean ip
folderItem = null;
folder = null;
shell = null;
//return mp3File instance
return mp3File;
}
}
}
Bits in bold are bits that are changed - it basically checks if your running vista, and if you are uses vista's indexes.
- Javawag
|
|
|
|
 |
|
 |
I mean shell32 must have a way of retrieving it...
btw, thanks for the code, it sure helped me with my project.
|
|
|
|
 |
|
|
 |
|
 |
When I tried to run this on Vista, the IDs (item indexes) appear to have changed. I used these IDs for the info that I needed:
13 (or 20--they were the same for every file I checked) is the artist
14 is the album
21 is the song title
26 is the track number.
I hope that helps anyone that is using this in the future!
|
|
|
|
 |
|
 |
When I tried to run this on Vista, the IDs (item indexes) appear to have changed. I used these IDs for the info that I needed:
13 (or 20--they were the same for every file I checked) is the artist
14 is the album
21 is the song title
26 is the track number.
I hope that helps anyone that is using this in the future!
|
|
|
|
 |
|
 |
Do you know what the rest of the Indexes are for Vista?
|
|
|
|
 |
|
 |
Nice article. Here's a few C# tips:
-If you can't actually modify a property, don't implement set{}.
-You can do the extraction in the constructor of the class containing the data. This incurs no overhead.
-If the constructor is going to fail for some reason, throw an exception.
-The Shell object is reusable; initialize it once statically and use it for the whole life of the process.
-Use the System.IO.Path methods to extract full path, directory name etc.
-structs are only more efficient, at current, if they are less than 16 bytes, so best practice in this case would be to use classes instead.
Here's how I wrote the class according to your article:
public class Mp3File
{
static Shell shell = new ShellClass();
public Mp3File(string path)
{
this.path = System.IO.Path.GetFullPath(path);
Folder folder = shell.NameSpace(System.IO.Path.GetDirectoryName(path));
FolderItem item = folder.ParseName(System.IO.Path.GetFileName(path));
if (item == null)
throw new System.InvalidOperationException();
this.path = System.IO.Path.GetFullPath(path);
this.artist = folder.GetDetailsOf(item, 9);
this.album = folder.GetDetailsOf(item, 17);
this.title = folder.GetDetailsOf(item, 10);
this.track = folder.GetDetailsOf(item, 19);
}
string path;
public string Path
{
get { return path; }
}
string artist;
public string Artist
{
get { return artist; }
}
string album;
public string Album
{
get { return album; }
}
string title;
public string Title
{
get { return title; }
}
string track;
public string Track
{
get { return track; }
}
}
|
|
|
|
 |
|
 |
Iam also facing the same problem. The above article is very helpful.
I am trying to read and write audio metadata. its very easy to Get metadata using "mediaFile.ArtistName = folder.GetDetailsOf(folderItem, n)" but i can't seem to find any methods to Set the values.
Is there any way to write using the same shell32 implementation. Please reply to this message.
Prashanth
C# Newbie
-- modified at 11:56 Friday 16th December, 2005
|
|
|
|
 |
|
 |
Hi,
I went through the code given for reading the ID3 tag and that was really very helpful. I also went through various discussions but what caught by attention was the suggestion of reading ID3 tag from binary file which will be a more generic solution across different OS. Can anyone help me in telling how do we achieve this?
namrata
|
|
|
|
 |
|
 |
check out the implementations section at http://id3.org
|
|
|
|
 |
|
 |
How could i read those....i cant find a way Any ideas?
|
|
|
|
 |
|
|
 |
|
 |
I am trying to read and write audio metadata (mp3/wma). its very easy to Get metadata using "mediaFile.ArtistName = folder.GetDetailsOf(folderItem, n)" but i cant seem to find any methods to Set the values. can this be done in the shell? if not, does anyone know an easy way of setting metdata tags?... i have parsed the verbs on an audio file but nothing lets me change the metadata...
Laurence Fass
|
|
|
|
 |
|
 |
Iam also facing the same problem. The above article is very helpful.
I am trying to read and write audio metadata (mp3/wma). its very easy to Get metadata using "mediaFile.ArtistName = folder.GetDetailsOf(folderItem, n)" but i can't seem to find any methods to Set the values.
Is there any way to write using the same sheel32 implementation. Please reply to this message.
Prashanth
C# Newbie
|
|
|
|
 |
|
 |
I have been experiencing two problems with the project.
When I click on the button to open the folder search screen I receive the following error:
The procedure entry point RtlDuplicateUnicodeString could not be located in the dynamic link library ntdll.dll
The window still loaded so I persisted to locating my files.
When I clicked the Read Tags button, no tags were read. The songs have been tagged by Musicmatch.
I tried several different directories all with the same results.
From my perspective, it doesn't work on a W2K box running .net 2003.
Does anyone have a good mp3 tag reader that can be compiled either as a dll or can be incorporated into a vb.net application? Anyone at all?
mpg
|
|
|
|
 |
|
 |
hi,
yes, the RtlDuplicateCodeString is a known issue that apparently manifests itself when packages that are meant to be installed on WinXP are installed on Win2K .. more on that here
http://www.answers.google.com/answers/threadview?id=366517[^]
as i have already indicated in the article, you may find these other implementations more suitable for your needs ..
[^]
Cheers,
|
|
|
|
 |
|
 |
I got the same problem then i recompiled for x86 only and it worked fine.
Stephen Remde
|
|
|
|
 |
|
 |
I got an exception: Input string was not in the correct format.
However on windows xp works well (it reads the ID3v2 tags - which is normally quite complicated).
|
|
|
|
 |
|
 |
I use WindowsXP and it doesnt seem to work here.I also got an exception: Input string was not in correct format.
|
|
|
|
 |
|
 |
I received the same error and on investigation it was because the track number field on some songs was null. A simple error check on this line
mp3File.TrackNumber = Int32.Parse(folder.GetDetailsOf(folderItem,19));
can prevent an app crash and an integer value such as 0 can be entered.
|
|
|
|
 |
|
 |
enum DetailColumns
{
InfoTip = -1,
Name = 0,
Size = 1,
Type = 2,
DateLastModified = 3,
DateCreated = 4,
DateLastAccessed = 5,
Attributes = 6,
Status = 7,
Owner = 8,
Author = 9,
Title = 10,
Subject = 11,
Category = 12,
Pages = 13,
Comments = 14,
Artist = 16,
AlbumTitle = 17,
Year = 18,
TrackNumber = 19,
Genre = 20,
Duration = 21,
Bitrate = 22,
Protected = 23,
Dimensions = 26,
Width = 27,
Height = 28,
Company = 30,
Description = 31,
FileVersion = 32,
ProductName = 33,
ProductVersion = 34
}
greetz
*Niels Penneman*
Software/Dev Site Personal Site
|
|
|
|
 |
|
 |
*Never Mind*
-- modified at 22:45 Tuesday 7th February, 2006
|
|
|
|
 |