Mac Forums

Mac Forums (http://www.mac-forums.com/forums/)
-   OS X - Development and Darwin (http://www.mac-forums.com/forums/os-x-development-darwin/)
-   -   Reading ID3 tags from an audio file. (http://www.mac-forums.com/forums/os-x-development-darwin/189880-reading-id3-tags-audio-file.html)

fajhetti 02-05-2010 12:17 PM

Reading ID3 tags from an audio file.
 
We allow customers in our application to select their own mp3 to put with an "order". When they do I need to be able to read the length of the song in seconds.

I have tried the AudioToolbox and QTKit unsuccessfully. I am not an extremely experienced objective-c, but can get around a little.

Thank you very much for your help.

Code:

-(IBAction)AddMusicFile:(id)sender
{
        int iResponse = NSRunAlertPanel(@"Add Song",
                                        @"By clicking yes, you confirm that you have purchased the song(s) you are uploading and have the rights to use the music for the intended purpose.",
                                        @"Yes", @"No", /*ThirdButtonHere:*/nil
                                        /*, args for a printf-style msg go here */);
        switch(iResponse) {
                case NSAlertDefaultReturn:    /* user pressed OK */
                        break;
                case NSAlertAlternateReturn:  /* user pressed Cancel */
                        return;
                        break;
                case NSAlertOtherReturn:      /* user pressed the third button */
                        return;
                        break;
                case NSAlertErrorReturn:      /* an error occurred */
                        return;
                        break;
        }
       
        Package *order = CurrentPackage;
        NSString * songName = [self AddMusicFileToOrder:order.PackageNumber];
       
        if (songName != nil)
        {
                SlideShowSong * showSong = [SlideShowSong new];
                showSong.MusicName = songName;
                showSong.CustomerUploaded = TRUE;
       
                NSInteger val = 0;
                for(SlideShowSong * song in [SelectedMusicInfoController content])
                        if (song.Ordinal > val)
                                val  = song.Ordinal;
               
                //RIGHT HERE I HAVE TO READ IN THE ID3 TAGS AND DETERMINE TOTAL LENGTH OF THE SONG IN SECONDS.
       
                showSong.Ordinal = val + 1;
               
                for(SlideShowSong * song in [SelectedMusicInfoController content])
                {
                        if ([song.MusicName isEqualToString:showSong.MusicName])
                                return;
                }
               
                [SelectedMusicInfoController addObject:showSong];
        }
       
}



All times are GMT -4. The time now is 08:31 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.