diff --git a/projects/macosx/frontrow_plugin/FRVLC.xcodeproj/project.pbxproj b/projects/macosx/frontrow_plugin/FRVLC.xcodeproj/project.pbxproj index 8132760455..6fd5ec06a2 100644 --- a/projects/macosx/frontrow_plugin/FRVLC.xcodeproj/project.pbxproj +++ b/projects/macosx/frontrow_plugin/FRVLC.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 6322C2AC0D609FEC00B020BB /* VLCMediaListController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6322C2AB0D609FEC00B020BB /* VLCMediaListController.m */; }; 63F954120D5B9B4C00616D1F /* VLCKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63F954110D5B9B4C00616D1F /* VLCKit.framework */; }; 8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; }; 8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; @@ -42,24 +43,14 @@ }; /* End PBXContainerItemProxy section */ -/* Begin PBXCopyFilesBuildPhase section */ - A79488020C9089F800B97E56 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - /* Begin PBXFileReference section */ 089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; 089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; 089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; 32DBCF630370AF2F00C91783 /* FRVLC_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FRVLC_Prefix.pch; sourceTree = ""; }; + 6322C2AA0D609FEC00B020BB /* VLCMediaListController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCMediaListController.h; sourceTree = ""; }; + 6322C2AB0D609FEC00B020BB /* VLCMediaListController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCMediaListController.m; sourceTree = ""; }; 63F954110D5B9B4C00616D1F /* VLCKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = VLCKit.framework; path = ../framework/build/Debug/VLCKit.framework; sourceTree = SOURCE_ROOT; }; 8D5B49B6048680CD000E48DA /* VLC.frappliance */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VLC.frappliance; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -147,6 +138,8 @@ A730338A0C8796BA00DA8E0A /* VLCAppliance.m */, A70B95850C8F889500D5A5FF /* VLCApplianceController.h */, A70B95860C8F889500D5A5FF /* VLCApplianceController.m */, + 6322C2AA0D609FEC00B020BB /* VLCMediaListController.h */, + 6322C2AB0D609FEC00B020BB /* VLCMediaListController.m */, A70B959A0C8F936500D5A5FF /* VLCPlayerController.h */, A70B959B0C8F936500D5A5FF /* VLCPlayerController.m */, ); @@ -208,11 +201,10 @@ isa = PBXNativeTarget; buildConfigurationList = 1DEB913A08733D840010E9CD /* Build configuration list for PBXNativeTarget "FRVLC" */; buildPhases = ( + 63F956E80D5B9D4800616D1F /* ShellScript */, 8D5B49AF048680CD000E48DA /* Resources */, 8D5B49B1048680CD000E48DA /* Sources */, 8D5B49B3048680CD000E48DA /* Frameworks */, - A79488020C9089F800B97E56 /* CopyFiles */, - 63F956E80D5B9D4800616D1F /* ShellScript */, ); buildRules = ( ); @@ -285,7 +277,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if test \"$SYMROOT\" == \"$PROJECT_DIR/build\"\nthen\n\tVLCFRAMEWORK=\"$SRCROOT/../Framework/build/$CONFIGURATION/VLCKit.framework\"\nelse\n\tVLCFRAMEWORK=\"$SYMROOT/$CONFIGURATION/VLCKit.framework\"\nfi\n/Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/pbxcp -exclude .DS_Store -exclude CVS -exclude .svn -resolve-src-symlinks $VLCFRAMEWORK $BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH\n\n\n"; + shellScript = "if test \"$SYMROOT\" == \"$PROJECT_DIR/build\"\nthen\n\tVLCFRAMEWORK=\"$SRCROOT/../Framework/build/$CONFIGURATION/VLCKit.framework\"\nelse\n\tVLCFRAMEWORK=\"$SYMROOT/$CONFIGURATION/VLCKit.framework\"\nfi\nmkdir -p $BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH\n/Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/pbxcp -exclude .DS_Store -exclude CVS -exclude .svn -resolve-src-symlinks $VLCFRAMEWORK $BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH\n\n\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -300,6 +292,7 @@ A70B958A0C8F88CF00D5A5FF /* VLCDebug.m in Sources */, A70B959C0C8F936500D5A5FF /* VLCPlayerController.m in Sources */, A7E542900C960B5500EBBC34 /* VLCMediaLayer.m in Sources */, + 6322C2AC0D609FEC00B020BB /* VLCMediaListController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -343,7 +336,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = FRVLC_Prefix.pch; INFOPLIST_FILE = Info.plist; - INSTALL_PATH = "$(HOME)/Library/Bundles"; + INSTALL_PATH = "$(SYSTEM)/Library/CoreServices/Front\\ Row.app/PlugIns"; PRODUCT_NAME = VLC; WRAPPER_EXTENSION = frappliance; ZERO_LINK = YES; @@ -365,7 +358,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = FRVLC_Prefix.pch; INFOPLIST_FILE = Info.plist; - INSTALL_PATH = "$(HOME)/Library/Bundles"; + INSTALL_PATH = "$(SYSTEM)/Library/CoreServices/Front\\ Row.app/PlugIns"; PRODUCT_NAME = VLC; WRAPPER_EXTENSION = frappliance; }; diff --git a/projects/macosx/frontrow_plugin/VLCAppliance.m b/projects/macosx/frontrow_plugin/VLCAppliance.m index f342337bb4..b622575b16 100644 --- a/projects/macosx/frontrow_plugin/VLCAppliance.m +++ b/projects/macosx/frontrow_plugin/VLCAppliance.m @@ -6,9 +6,12 @@ // Copyright 2007 __MyCompanyName__. All rights reserved. // +#import + #import "VLCAppliance.h" #import "VLCApplianceController.h" +#import "VLCMediaListController.h" @implementation VLCAppliance @@ -24,6 +27,10 @@ - (id)applianceController { + // Disabled until we properly display a menu for that. You can test it by uncommenting those lines, and comment the following line. + // VLCMediaListAspect * mediaListAspect = [[[[VLCMediaDiscoverer alloc] initWithName:@"freebox"] discoveredMedia] hierarchicalAspect]; + // VLCApplianceController * controller = [[VLCMediaListController alloc] initWithMediaListAspect:mediaListAspect]; + VLCApplianceController * controller = [[VLCApplianceController alloc] initWithPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Movies"]]; return [controller autorelease]; diff --git a/projects/macosx/frontrow_plugin/VLCApplianceController.m b/projects/macosx/frontrow_plugin/VLCApplianceController.m index 50e70427bc..24029056bd 100644 --- a/projects/macosx/frontrow_plugin/VLCApplianceController.m +++ b/projects/macosx/frontrow_plugin/VLCApplianceController.m @@ -195,7 +195,7 @@ playerController = [[VLCPlayerController alloc] init]; } - playerController.path = path; + playerController.media = [VLCMedia mediaWithPath:path]; controller = playerController; #endif } diff --git a/projects/macosx/frontrow_plugin/VLCMediaLayer.h b/projects/macosx/frontrow_plugin/VLCMediaLayer.h index 4600f00388..466ab1d36d 100644 --- a/projects/macosx/frontrow_plugin/VLCMediaLayer.h +++ b/projects/macosx/frontrow_plugin/VLCMediaLayer.h @@ -17,7 +17,7 @@ VLCMediaPlayer * _player; } -@property(retain, nonatomic) NSURL * url; +@property(retain, nonatomic) VLCMedia * media; @property(readonly) VLCMediaPlayer * player; diff --git a/projects/macosx/frontrow_plugin/VLCMediaLayer.m b/projects/macosx/frontrow_plugin/VLCMediaLayer.m index 1d51317932..9c054a4b95 100644 --- a/projects/macosx/frontrow_plugin/VLCMediaLayer.m +++ b/projects/macosx/frontrow_plugin/VLCMediaLayer.m @@ -23,7 +23,7 @@ [super dealloc]; } -- (void)setUrl:(NSURL*)url +- (void)setMedia:(VLCMedia*)media { #if 0 if(_videoLayer != nil) { @@ -56,19 +56,23 @@ } #endif - NSLog(@"playing url: %@", url); + NSLog(@"playing media: %@", media); - VLCMedia * media = [VLCMedia mediaWithURL:url]; [_player setMedia:media]; } -- (NSURL*)url +- (VLCMedia *)media +{ + return [_player media]; +} + +- (VLCMedia *)url { if(_player == nil) { return nil; } else { - return [[_player media] url]; + return [_player media]; } } diff --git a/projects/macosx/frontrow_plugin/VLCMediaListController.h b/projects/macosx/frontrow_plugin/VLCMediaListController.h new file mode 100644 index 0000000000..a3b904b3a9 --- /dev/null +++ b/projects/macosx/frontrow_plugin/VLCMediaListController.h @@ -0,0 +1,21 @@ +// +// VLCMediaListController.h +// FRVLC +// +// Created by Pierre d'Herbemont on 2/11/08. +// Copyright 2008 __MyCompanyName__. All rights reserved. +// + +#import +#import +#import + + +@interface VLCMediaListController : BRMenuController { + VLCMediaListAspect * mediaListAspect; + BOOL isReloading; +} + +- initWithMediaListAspect:(VLCMediaListAspect *)mediaListAspect; + +@end diff --git a/projects/macosx/frontrow_plugin/VLCMediaListController.m b/projects/macosx/frontrow_plugin/VLCMediaListController.m new file mode 100644 index 0000000000..167ae6d88c --- /dev/null +++ b/projects/macosx/frontrow_plugin/VLCMediaListController.m @@ -0,0 +1,143 @@ +// +// VLCMediaListController.m +// FRVLC +// +// Created by Pierre d'Herbemont on 2/11/08. +// Copyright 2008 __MyCompanyName__. All rights reserved. +// + +#import "VLCMediaListController.h" +#import "VLCPlayerController.h" + +#import +#import +#import + +@interface VLCMediaListController () + +@property(retain, nonatomic) VLCMediaListAspect * mediaListAspect; + +@end + +@implementation VLCMediaListController + +@synthesize mediaListAspect; + +- initWithMediaListAspect:(VLCMediaListAspect *)aMediaListAspect +{ + self = [super init]; + + self.mediaListAspect = aMediaListAspect; + [self.mediaListAspect addObserver:self forKeyPath:@"media" options:NSKeyValueChangeRemoval|NSKeyValueChangeInsertion|NSKeyValueChangeSetting context:nil]; + [[self list] setDatasource:self]; + isReloading = NO; + + return self; +} + +- (void)dealloc +{ + [self.mediaListAspect removeObserver:self forKeyPath:@"media"]; + [mediaListAspect release]; + [super dealloc]; +} + +- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context +{ + if ([keyPath isEqualToString:@"media"]) { + if(!isReloading) + { + isReloading = YES; + [self performSelector:@selector(reload) withObject:nil afterDelay:2.]; + } + } + else { + [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; + } +} + +- (void)willBePushed +{ + PRINT_ME(); +} + +- (void)willBePopped +{ + PRINT_ME(); +} + +#pragma mark - +#pragma mark Reload hack + +- (void) reload +{ + [[self list] reload]; + isReloading = NO; +} + +#pragma mark - +#pragma mark Data source + +- (NSInteger)itemCount +{ + return [mediaListAspect count]; +} + +- (CGFloat)heightForRow:(NSInteger)row +{ + return 64.0; +} + +- (BOOL)rowSelectable:(NSInteger)row +{ + return YES; +} + +- (NSString*)titleForRow:(NSInteger)row +{ + return [[mediaListAspect mediaAtIndex:row] valueForKeyPath:@"metaDictionary.title"]; +} + +- (id)itemForRow:(NSInteger)row +{ + BOOL isDirectory = ![[mediaListAspect nodeAtIndex:row] isLeaf]; + + BRTextMenuItemLayer * item = nil; + + if(isDirectory) { + item = [BRTextMenuItemLayer folderMenuItem]; + } + else { + item = [BRTextMenuItemLayer menuItem]; + } + + [item setTitle:[self titleForRow:row]]; + + return item; +} + +- (void)itemSelected:(NSInteger)row +{ + BOOL isDirectory = ![[mediaListAspect nodeAtIndex:row] isLeaf]; + + BRController * controller = nil; + + if(isDirectory) { + controller = [[[VLCMediaListController alloc] initWithMediaListAspect:[[mediaListAspect nodeAtIndex:row] children]] autorelease]; + } + else { + static VLCPlayerController * playerController = nil; + if(playerController == nil) { + playerController = [[VLCPlayerController alloc] init]; + } + + playerController.media = [mediaListAspect mediaAtIndex:row]; + controller = playerController; + } + + if(controller != nil) { + [[self stack] pushController:controller]; + } +} + +@end \ No newline at end of file diff --git a/projects/macosx/frontrow_plugin/VLCPlayerController.h b/projects/macosx/frontrow_plugin/VLCPlayerController.h index f4513f04d1..f026043cff 100644 --- a/projects/macosx/frontrow_plugin/VLCPlayerController.h +++ b/projects/macosx/frontrow_plugin/VLCPlayerController.h @@ -9,12 +9,13 @@ #import #import #import "VLCMediaLayer.h" +#import @interface VLCPlayerController : BRController { VLCMediaLayer * _mediaLayer; } -@property(retain) NSString * path; +@property(retain) VLCMedia * media; @end diff --git a/projects/macosx/frontrow_plugin/VLCPlayerController.m b/projects/macosx/frontrow_plugin/VLCPlayerController.m index 7eeeb43413..b74229e54b 100644 --- a/projects/macosx/frontrow_plugin/VLCPlayerController.m +++ b/projects/macosx/frontrow_plugin/VLCPlayerController.m @@ -7,6 +7,7 @@ // #import "VLCPlayerController.h" + #import #import #import @@ -27,14 +28,14 @@ return self; } -- (NSString*)path +- (VLCMedia *)media { - return [_mediaLayer.url path]; + return [_mediaLayer media]; } -- (void)setPath:(NSString*)path +- (void)setMedia:(VLCMedia *)media { - _mediaLayer.url = [NSURL fileURLWithPath:path]; + _mediaLayer.media = media; } - (void)brEventAction:(BREvent*)event