]> git.sesse.net Git - vlc/commitdiff
macosx/frontrow_plugin: VLCMediaListController, display a mediaListAspect in a FrontR...
authorPierre d'Herbemont <pdherbemont@videolan.org>
Tue, 12 Feb 2008 21:01:21 +0000 (21:01 +0000)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Tue, 12 Feb 2008 21:01:21 +0000 (21:01 +0000)
projects/macosx/frontrow_plugin/FRVLC.xcodeproj/project.pbxproj
projects/macosx/frontrow_plugin/VLCAppliance.m
projects/macosx/frontrow_plugin/VLCApplianceController.m
projects/macosx/frontrow_plugin/VLCMediaLayer.h
projects/macosx/frontrow_plugin/VLCMediaLayer.m
projects/macosx/frontrow_plugin/VLCMediaListController.h [new file with mode: 0644]
projects/macosx/frontrow_plugin/VLCMediaListController.m [new file with mode: 0644]
projects/macosx/frontrow_plugin/VLCPlayerController.h
projects/macosx/frontrow_plugin/VLCPlayerController.m

index 8132760455ab9b0b064e9b300c8ade91d7bf5724..6fd5ec06a25f4b8eccb125217ec99133312b03d4 100644 (file)
@@ -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 */; };
                };
 /* 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 = "<absolute>"; };
                089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
                089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
                1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
                32DBCF630370AF2F00C91783 /* FRVLC_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FRVLC_Prefix.pch; sourceTree = "<group>"; };
+               6322C2AA0D609FEC00B020BB /* VLCMediaListController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCMediaListController.h; sourceTree = "<group>"; };
+               6322C2AB0D609FEC00B020BB /* VLCMediaListController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCMediaListController.m; sourceTree = "<group>"; };
                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 = "<group>"; };
                                A730338A0C8796BA00DA8E0A /* VLCAppliance.m */,
                                A70B95850C8F889500D5A5FF /* VLCApplianceController.h */,
                                A70B95860C8F889500D5A5FF /* VLCApplianceController.m */,
+                               6322C2AA0D609FEC00B020BB /* VLCMediaListController.h */,
+                               6322C2AB0D609FEC00B020BB /* VLCMediaListController.m */,
                                A70B959A0C8F936500D5A5FF /* VLCPlayerController.h */,
                                A70B959B0C8F936500D5A5FF /* VLCPlayerController.m */,
                        );
                        isa = PBXNativeTarget;
                        buildConfigurationList = 1DEB913A08733D840010E9CD /* Build configuration list for PBXNativeTarget "FRVLC" */;
                        buildPhases = (
+                               63F956E80D5B9D4800616D1F /* ShellScript */,
                                8D5B49AF048680CD000E48DA /* Resources */,
                                8D5B49B1048680CD000E48DA /* Sources */,
                                8D5B49B3048680CD000E48DA /* Frameworks */,
-                               A79488020C9089F800B97E56 /* CopyFiles */,
-                               63F956E80D5B9D4800616D1F /* ShellScript */,
                        );
                        buildRules = (
                        );
                        );
                        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 */
                                A70B958A0C8F88CF00D5A5FF /* VLCDebug.m in Sources */,
                                A70B959C0C8F936500D5A5FF /* VLCPlayerController.m in Sources */,
                                A7E542900C960B5500EBBC34 /* VLCMediaLayer.m in Sources */,
+                               6322C2AC0D609FEC00B020BB /* VLCMediaListController.m in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                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;
                                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;
                        };
index f342337bb44fd94d7dc266b54bfb7dbeb1f78cea..b622575b1617a4113ff3aab9606420a7bf824e02 100644 (file)
@@ -6,9 +6,12 @@
 //  Copyright 2007 __MyCompanyName__. All rights reserved.
 //
 
+#import <VLCKit/VLCKit.h>
+
 #import "VLCAppliance.h"
 
 #import "VLCApplianceController.h"
+#import "VLCMediaListController.h"
 
 @implementation VLCAppliance
 
 
 - (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];
index 50e70427bcb1554d08684fcf8d5b511cfb29ce86..24029056bd863bb5a21b9c9141e4e1e47675d819 100644 (file)
             playerController = [[VLCPlayerController alloc] init];
         }
         
-        playerController.path = path;
+        playerController.media = [VLCMedia mediaWithPath:path];
         controller = playerController;
 #endif
     }
index 4600f003881f76a59906f8fd9cbb9f16cc379c69..466ab1d36d5e4c869a98bcc5a97826e3481c65c7 100644 (file)
@@ -17,7 +17,7 @@
     VLCMediaPlayer * _player;
 }
 
-@property(retain, nonatomic) NSURL * url;
+@property(retain, nonatomic) VLCMedia * media;
 
 @property(readonly) VLCMediaPlayer * player;
 
index 1d51317932189e5ecbf05810927dba7f3a8dac27..9c054a4b951572933f4c222c59a44f05fe3349b5 100644 (file)
@@ -23,7 +23,7 @@
     [super dealloc];
 }
 
-- (void)setUrl:(NSURL*)url
+- (void)setMedia:(VLCMedia*)media
 {
 #if 0
     if(_videoLayer != nil) {
     }
 #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 (file)
index 0000000..a3b904b
--- /dev/null
@@ -0,0 +1,21 @@
+//
+//  VLCMediaListController.h
+//  FRVLC
+//
+//  Created by Pierre d'Herbemont on 2/11/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+#import <VLCKit/VLCKit.h>
+#import <BackRow/BRMenuController.h>
+
+
+@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 (file)
index 0000000..167ae6d
--- /dev/null
@@ -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 <BackRow/BRListControl.h>
+#import <BackRow/BRTextMenuItemLayer.h>
+#import <BackRow/BRControllerStack.h>
+
+@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
index f4513f04d1c915925c5c7db502f51ee4f71ee79a..f026043cff70741aeb8cd5f4ce93978a7eae3264 100644 (file)
@@ -9,12 +9,13 @@
 #import <Cocoa/Cocoa.h>
 #import <BackRow/BRMediaPlayerController.h>
 #import "VLCMediaLayer.h"
+#import <VLCKit/VLCKit.h>
 
 @interface VLCPlayerController : BRController
 {
     VLCMediaLayer * _mediaLayer;
 }
 
-@property(retain) NSString * path;
+@property(retain) VLCMedia * media;
 
 @end
index 7eeeb434138e1c54b2fc4fe1ab96f6a3116eceba..b74229e54b01b52f52d4acfafe54bd8044cd9230 100644 (file)
@@ -7,6 +7,7 @@
 //
 
 #import "VLCPlayerController.h"
+
 #import <BackRow/BREvent.h>
 #import <BackRow/BRLayer.h>
 #import <BackRow/BRControllerStack.h>
     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