Added metadata reader for game music files.
parent
8c4f5fa41c
commit
286268e5ac
|
@ -18,6 +18,8 @@
|
|||
17C8F3C30CBED649008D969D /* GME.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 17C8F3370CBED393008D969D /* GME.framework */; };
|
||||
17C8F3E00CBEDBE0008D969D /* GamePlugin.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 17C8F3DE0CBEDBE0008D969D /* GamePlugin.h */; };
|
||||
17C8F3E10CBEDBE0008D969D /* GamePlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 17C8F3DF0CBEDBE0008D969D /* GamePlugin.m */; };
|
||||
17DA34BA0CC052030003F6B2 /* GameMetadataReader.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 17DA34B80CC052030003F6B2 /* GameMetadataReader.h */; };
|
||||
17DA34BB0CC052030003F6B2 /* GameMetadataReader.m in Sources */ = {isa = PBXBuildFile; fileRef = 17DA34B90CC052030003F6B2 /* GameMetadataReader.m */; };
|
||||
8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; };
|
||||
8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
@ -52,6 +54,7 @@
|
|||
17C8F3450CBED3BE008D969D /* GamePropertiesReader.h in CopyFiles */,
|
||||
17C8F3480CBED3C7008D969D /* Plugin.h in CopyFiles */,
|
||||
17C8F3E00CBEDBE0008D969D /* GamePlugin.h in CopyFiles */,
|
||||
17DA34BA0CC052030003F6B2 /* GameMetadataReader.h in CopyFiles */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -72,6 +75,8 @@
|
|||
17C8F3470CBED3C7008D969D /* Plugin.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Plugin.h; path = ../../Audio/Plugin.h; sourceTree = SOURCE_ROOT; };
|
||||
17C8F3DE0CBEDBE0008D969D /* GamePlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GamePlugin.h; sourceTree = "<group>"; };
|
||||
17C8F3DF0CBEDBE0008D969D /* GamePlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GamePlugin.m; sourceTree = "<group>"; };
|
||||
17DA34B80CC052030003F6B2 /* GameMetadataReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameMetadataReader.h; sourceTree = "<group>"; };
|
||||
17DA34B90CC052030003F6B2 /* GameMetadataReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameMetadataReader.m; sourceTree = "<group>"; };
|
||||
32DBCF630370AF2F00C91783 /* GME_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GME_Prefix.pch; sourceTree = "<group>"; };
|
||||
8D5B49B6048680CD000E48DA /* GME.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GME.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
|
@ -133,6 +138,8 @@
|
|||
17C8F33E0CBED3BE008D969D /* GameDecoder.m */,
|
||||
17C8F33F0CBED3BE008D969D /* GamePropertiesReader.h */,
|
||||
17C8F3400CBED3BE008D969D /* GamePropertiesReader.m */,
|
||||
17DA34B80CC052030003F6B2 /* GameMetadataReader.h */,
|
||||
17DA34B90CC052030003F6B2 /* GameMetadataReader.m */,
|
||||
);
|
||||
name = Classes;
|
||||
sourceTree = "<group>";
|
||||
|
@ -254,6 +261,7 @@
|
|||
17C8F3440CBED3BE008D969D /* GameDecoder.m in Sources */,
|
||||
17C8F3460CBED3BE008D969D /* GamePropertiesReader.m in Sources */,
|
||||
17C8F3E10CBEDBE0008D969D /* GamePlugin.m in Sources */,
|
||||
17DA34BB0CC052030003F6B2 /* GameMetadataReader.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
//
|
||||
// GameMetadataReader.h
|
||||
// GME
|
||||
//
|
||||
// Created by Vincent Spader on 10/12/07.
|
||||
// Copyright 2007 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import "Plugin.h"
|
||||
|
||||
@interface GameMetadataReader : NSObject <CogMetadataReader> {
|
||||
|
||||
}
|
||||
|
||||
@end
|
|
@ -0,0 +1,72 @@
|
|||
//
|
||||
// GameMetadataReader.m
|
||||
// GME
|
||||
//
|
||||
// Created by Vincent Spader on 10/12/07.
|
||||
// Copyright 2007 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import "GameMetadataReader.h"
|
||||
|
||||
#import "GameContainer.h"
|
||||
|
||||
#import <GME/gme.h>
|
||||
|
||||
@implementation GameMetadataReader
|
||||
|
||||
+ (NSArray *)fileTypes
|
||||
{
|
||||
return [GameContainer fileTypes];
|
||||
}
|
||||
|
||||
+ (NSDictionary *)metadataForURL:(NSURL *)url
|
||||
{
|
||||
if (![url isFileURL])
|
||||
return nil;
|
||||
|
||||
NSString *ext = [[[url path] pathExtension] lowercaseString];
|
||||
|
||||
gme_type_t type = gme_identify_extension([ext UTF8String]);
|
||||
if (!type)
|
||||
{
|
||||
NSLog(@"No type!");
|
||||
return NO;
|
||||
}
|
||||
|
||||
Music_Emu* emu;
|
||||
emu = gme_new_emu(type, gme_info_only);
|
||||
if (!emu)
|
||||
{
|
||||
NSLog(@"No new emu!");
|
||||
return NO;
|
||||
}
|
||||
|
||||
gme_err_t error;
|
||||
error = gme_load_file(emu, [[url path] UTF8String]);
|
||||
if (error)
|
||||
{
|
||||
NSLog(@"ERROR Loding file!");
|
||||
return NO;
|
||||
}
|
||||
|
||||
int track_num = [[url fragment] intValue]; //What if theres no fragment? Assuming we get 0.
|
||||
|
||||
track_info_t info;
|
||||
error = gme_track_info( emu, &info, track_num );
|
||||
if (error)
|
||||
{
|
||||
NSLog(@"Unable to get track info");
|
||||
}
|
||||
|
||||
gme_delete(emu);
|
||||
|
||||
return [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSString stringWithUTF8String: info.system], @"genre",
|
||||
[NSString stringWithUTF8String: info.game], @"album",
|
||||
[NSString stringWithUTF8String: info.song], @"title",
|
||||
[NSString stringWithUTF8String: info.author], @"artist",
|
||||
[NSNumber numberWithInt:track_num], @"track",
|
||||
nil];
|
||||
}
|
||||
|
||||
@end
|
|
@ -11,6 +11,7 @@
|
|||
#import "GameContainer.h"
|
||||
#import "GameDecoder.h"
|
||||
#import "GamePropertiesReader.h"
|
||||
#import "GameMetadataReader.h"
|
||||
|
||||
@implementation GamePlugin
|
||||
|
||||
|
@ -20,6 +21,7 @@
|
|||
kCogContainer, [GameContainer className],
|
||||
kCogDecoder, [GameDecoder className],
|
||||
kCogPropertiesReader, [GamePropertiesReader className],
|
||||
kCogMetadataReader, [GameMetadataReader className],
|
||||
nil];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue