Skip to content

Commit

Permalink
Added support for metadata loading
Browse files Browse the repository at this point in the history
  • Loading branch information
kallepersson committed Feb 15, 2012
1 parent b6904a7 commit 0735010
Show file tree
Hide file tree
Showing 7 changed files with 308 additions and 3 deletions.
2 changes: 2 additions & 0 deletions AppDelegate.h
Expand Up @@ -17,6 +17,8 @@
@property (weak) IBOutlet NSSlider *endSlider;
@property (weak) IBOutlet NSLevelIndicator *currentTimeBar;
@property (weak) IBOutlet NSTextField *currentTimeLabel;
@property (weak) IBOutlet NSTextField *currentTrackLabel;


@property (assign) BOOL paused;
@property (assign) double startTime;
Expand Down
10 changes: 10 additions & 0 deletions AppDelegate.m
Expand Up @@ -8,6 +8,7 @@

#import "AppDelegate.h"
#import <CoreAudio/CoreAudio.h>
#import "metadataRetriever.h"

@implementation AppDelegate

Expand All @@ -17,6 +18,7 @@ @implementation AppDelegate
@synthesize currentTimeLabel;
@synthesize currentTimeBar;
@synthesize playButton;
@synthesize currentTrackLabel;

@synthesize startTime;
@synthesize endTime;
Expand Down Expand Up @@ -57,6 +59,14 @@ - (void)loadMusic:(NSURL *) fileURL {
NSSound * m = [NSSound alloc];
music = [m initWithContentsOfURL:fileURL byReference:YES];
double maxValue = [music duration];

NSString * trackFilePath = [fileURL absoluteString];
trackFilePath = [trackFilePath stringByReplacingOccurrencesOfString:@"file://localhost" withString:@""];
NSArray *metadataArray = [metadataRetriever getMetadataForFile:trackFilePath];
[currentTrackLabel setStringValue:[NSString stringWithFormat:@"%@\n%@",[metadataArray objectAtIndex:1],[metadataArray objectAtIndex:0]]];



paused = YES;
startTime = 0.0;
endTime = maxValue;
Expand Down
10 changes: 10 additions & 0 deletions Perpetual.xcodeproj/project.pbxproj
Expand Up @@ -11,6 +11,8 @@
9395B6AD14EB88A8002999D9 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9395B6AC14EB88A8002999D9 /* QuartzCore.framework */; };
9395B6B014EB8D91002999D9 /* Podfile in Resources */ = {isa = PBXBuildFile; fileRef = 9395B6AF14EB8D91002999D9 /* Podfile */; };
9A041EBD14EAEBA2009AC43F /* cover.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 9A041EBC14EAEBA2009AC43F /* cover.jpg */; };
9A31AA3414EBF3FD00382B2F /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A31AA3314EBF3FD00382B2F /* AudioToolbox.framework */; };
9A31AA3814EBF49F00382B2F /* metadataRetriever.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A31AA3714EBF49F00382B2F /* metadataRetriever.m */; };
9AC739D314EAEAB6000A57AD /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AC739D214EAEAB6000A57AD /* Cocoa.framework */; };
9AC739DD14EAEAB6000A57AD /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 9AC739DB14EAEAB6000A57AD /* InfoPlist.strings */; };
9AC739DF14EAEAB6000A57AD /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AC739DE14EAEAB6000A57AD /* main.m */; };
Expand All @@ -24,6 +26,9 @@
9395B6AC14EB88A8002999D9 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
9395B6AF14EB8D91002999D9 /* Podfile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Podfile; sourceTree = "<group>"; };
9A041EBC14EAEBA2009AC43F /* cover.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = cover.jpg; sourceTree = "<group>"; };
9A31AA3314EBF3FD00382B2F /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
9A31AA3614EBF49F00382B2F /* metadataRetriever.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = metadataRetriever.h; sourceTree = "<group>"; };
9A31AA3714EBF49F00382B2F /* metadataRetriever.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = metadataRetriever.m; sourceTree = "<group>"; };
9AC739CE14EAEAB6000A57AD /* Perpetual.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Perpetual.app; sourceTree = BUILT_PRODUCTS_DIR; };
9AC739D214EAEAB6000A57AD /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
9AC739D514EAEAB6000A57AD /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
Expand All @@ -45,6 +50,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
9A31AA3414EBF3FD00382B2F /* AudioToolbox.framework in Frameworks */,
9395B6AD14EB88A8002999D9 /* QuartzCore.framework in Frameworks */,
9AC739D314EAEAB6000A57AD /* Cocoa.framework in Frameworks */,
351CA58DF08E43309D0C1A7C /* libPods.a in Frameworks */,
Expand All @@ -57,6 +63,7 @@
9AC739C314EAEAB6000A57AD = {
isa = PBXGroup;
children = (
9A31AA3314EBF3FD00382B2F /* AudioToolbox.framework */,
9395B6AC14EB88A8002999D9 /* QuartzCore.framework */,
9AC739D814EAEAB6000A57AD /* Perpetual */,
9AC739D114EAEAB6000A57AD /* Frameworks */,
Expand Down Expand Up @@ -96,6 +103,8 @@
9AC739D814EAEAB6000A57AD /* Perpetual */ = {
isa = PBXGroup;
children = (
9A31AA3614EBF49F00382B2F /* metadataRetriever.h */,
9A31AA3714EBF49F00382B2F /* metadataRetriever.m */,
9AC739E414EAEAB6000A57AD /* AppDelegate.h */,
9AC739E514EAEAB6000A57AD /* AppDelegate.m */,
9AC739E714EAEAB6000A57AD /* MainMenu.xib */,
Expand Down Expand Up @@ -204,6 +213,7 @@
files = (
9AC739DF14EAEAB6000A57AD /* main.m in Sources */,
9AC739E614EAEAB6000A57AD /* AppDelegate.m in Sources */,
9A31AA3814EBF49F00382B2F /* metadataRetriever.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Expand Up @@ -56,6 +56,11 @@
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
<AdditionalOption
key = "NSZombieEnabled"
value = "YES"
isEnabled = "YES">
</AdditionalOption>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
Expand Down
109 changes: 106 additions & 3 deletions en.lproj/MainMenu.xib
Expand Up @@ -2,7 +2,7 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1070</int>
<string key="IBDocument.SystemVersion">11D50b</string>
<string key="IBDocument.SystemVersion">11D50</string>
<string key="IBDocument.InterfaceBuilderVersion">1938</string>
<string key="IBDocument.AppKitVersion">1138.32</string>
<string key="IBDocument.HIToolboxVersion">568.00</string>
Expand Down Expand Up @@ -312,6 +312,7 @@
</set>
<string key="NSFrame">{{-3, 127}, {406, 256}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="690740704"/>
<string key="NSReuseIdentifierKey">_NS:2141</string>
<bool key="NSEnabled">YES</bool>
Expand All @@ -335,6 +336,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{8, 82}, {40, 40}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="353695766"/>
<string key="NSReuseIdentifierKey">_NS:687</string>
<bool key="NSEnabled">YES</bool>
Expand Down Expand Up @@ -366,6 +368,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{59, 86}, {245, 34}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="753304525"/>
<string key="NSReuseIdentifierKey">_NS:360</string>
<string key="NSAntiCompressionPriority">{250, 750}</string>
Expand Down Expand Up @@ -406,6 +409,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{319, 95}, {75, 17}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="752942585"/>
<string key="NSReuseIdentifierKey">_NS:3944</string>
<bool key="NSEnabled">YES</bool>
Expand All @@ -425,6 +429,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{18, 34}, {366, 16}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="75188771"/>
<string key="NSReuseIdentifierKey">_NS:2200</string>
<bool key="NSEnabled">YES</bool>
Expand All @@ -442,6 +447,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{9, 49}, {384, 26}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="840108087"/>
<string key="NSReuseIdentifierKey">_NS:3905</string>
<bool key="NSEnabled">YES</bool>
Expand All @@ -466,6 +472,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{9, 9}, {384, 25}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:3905</string>
<bool key="NSEnabled">YES</bool>
Expand All @@ -488,6 +495,7 @@
</array>
<string key="NSFrameSize">{400, 380}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="379503995"/>
</object>
<string key="NSScreenRect">{{0, 0}, {2560, 1440}}</string>
Expand Down Expand Up @@ -668,6 +676,14 @@
</object>
<int key="connectionID">612</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">currentTrackLabel</string>
<reference key="source" ref="976324537"/>
<reference key="destination" ref="353695766"/>
</object>
<int key="connectionID">613</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
Expand Down Expand Up @@ -1053,9 +1069,96 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">612</int>
<int key="maxID">613</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">AppDelegate</string>
<string key="superclassName">NSObject</string>
<dictionary class="NSMutableDictionary" key="actions">
<string key="currentTimeBarSet:">id</string>
<string key="endSliderSet:">id</string>
<string key="openFile:">id</string>
<string key="playButtonClick:">id</string>
<string key="startSliderSet:">id</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="actionInfosByName">
<object class="IBActionInfo" key="currentTimeBarSet:">
<string key="name">currentTimeBarSet:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="endSliderSet:">
<string key="name">endSliderSet:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="openFile:">
<string key="name">openFile:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="playButtonClick:">
<string key="name">playButtonClick:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="startSliderSet:">
<string key="name">startSliderSet:</string>
<string key="candidateClassName">id</string>
</object>
</dictionary>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="currentTimeBar">NSLevelIndicator</string>
<string key="currentTimeLabel">NSTextField</string>
<string key="currentTrackLabel">NSTextField</string>
<string key="endSlider">NSSlider</string>
<string key="playButton">NSButton</string>
<string key="startSlider">NSSlider</string>
<string key="window">INAppStoreWindow</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="currentTimeBar">
<string key="name">currentTimeBar</string>
<string key="candidateClassName">NSLevelIndicator</string>
</object>
<object class="IBToOneOutletInfo" key="currentTimeLabel">
<string key="name">currentTimeLabel</string>
<string key="candidateClassName">NSTextField</string>
</object>
<object class="IBToOneOutletInfo" key="currentTrackLabel">
<string key="name">currentTrackLabel</string>
<string key="candidateClassName">NSTextField</string>
</object>
<object class="IBToOneOutletInfo" key="endSlider">
<string key="name">endSlider</string>
<string key="candidateClassName">NSSlider</string>
</object>
<object class="IBToOneOutletInfo" key="playButton">
<string key="name">playButton</string>
<string key="candidateClassName">NSButton</string>
</object>
<object class="IBToOneOutletInfo" key="startSlider">
<string key="name">startSlider</string>
<string key="candidateClassName">NSSlider</string>
</object>
<object class="IBToOneOutletInfo" key="window">
<string key="name">window</string>
<string key="candidateClassName">INAppStoreWindow</string>
</object>
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/AppDelegate.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">INAppStoreWindow</string>
<string key="superclassName">NSWindow</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/INAppStoreWindow.h</string>
</object>
</object>
</array>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
Expand Down
22 changes: 22 additions & 0 deletions metadataRetriever.h
@@ -0,0 +1,22 @@
//
// metadataRetriever.h
// SwiftLoad
//
// Created by Nathaniel Symer on 12/20/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioToolbox.h>

@interface metadataRetriever : NSObject

+ (NSArray *)getMetadataForFile:(NSString *)filePath;

+ (NSString *)artistForMetadataArray:(NSArray *)array;

+ (NSString *)songForMetadataArray:(NSArray *)array;

+ (NSString *)albumForMetadataArray:(NSArray *)array;

@end

0 comments on commit 0735010

Please sign in to comment.