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.
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];
}
}