|
 |
|
|
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.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Change your ShellID3TagReader.cs file to this:
using System;
namespace Renamer { public struct ShellID3TagReader { public static MP3File ReadID3Tags(string FileFullPath){ MP3File mp3File = new MP3File();
//parse file name 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
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I mean shell32 must have a way of retrieving it... btw, thanks for the code, it sure helped me with my project.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
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!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
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!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
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; } } }
|
| Sign In·View Thread·PermaLink | 3.89/5 (4 votes) |
|
|
|
 |
|
|
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
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
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
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 |
|
|
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
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
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
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
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
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
|
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).
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I use WindowsXP and it doesnt seem to work here.I also got an exception: Input string was not in correct format.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
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.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
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
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
Interesting article. I had a couple of questions; 1. How did you find out the item index for the value you were trying to get using GetDetailsOf()? Specifically, how did you know that the artist name is located at index 9 in this line of code? mp3File.ArtistName = folder.GetDetailsOf(folderItem,9);
2. Since the Shell32 dll is different for different versions of Windows, will the indexes be different too?
Thanks!
"Know your role"
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
A1: It's buried in the Platform SDK documentation for the shell's Folder class and IShellFolder2. Basically, the SHCOLUMNID uniquely defines columns and adds them to the shell view (either visibly or invisibly) in a particular order. The GetDetailsOf abstracts this away and allows you to refer to them by index in relation to that order.
A2: Not only *could* this be different on different versions of Windows, if *could* be different from computer to computer, depending on how a user rearranges their columns (either visible or invisible)! This is a very bad method of doing this.
Normally, however, the Win32 APIs don't change or remove functionality from version to version (usually). Most times, functions are superceeded by newer methods (usually ending in "Ex") and constants (or structs like SHCOLUMNID) are *added*. Familiarization with the Platform SDK is helpful in understanding this.
-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
arguments A1 and A2 are not factually correct: the value passed to the GetDetailsOf function is not the ordinal index of the visible location of the column, ie. if your column headers were re-ordered manually you will still be able to extract the same information. infact, the columnheaders don't even need to be visible at all, you can turn them off manually and you would still be able to extract the same tag information.
i took a short cut and hardcoded the items only relevant to MP3 files. if you wish you could of course enumerate all possible SHCOLUMNID structures by calling GetDetailsEx with the pidl param as null etc etc. which would be beyond the scope of this article.
|
| Sign In·View Thread·PermaLink | 2.00/5 (2 votes) |
|
|
|
 |
|
|
If you re-read my post, I stated that the index is for both visible and invisible columns. It has to do with the order that the OS maintains for the columns, which could be different.
Besides, the correct way of doing this is reading the ID3 tag from the binary file. There's no chance of differences there, even between OS's.
-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |