macosx/framework: Add VLCMediaListPlayer.
authorPierre d'Herbemont <pdherbemont@free.fr>
Mon, 24 Aug 2009 15:17:02 +0000 (17:17 +0200)
committerPierre d'Herbemont <pdherbemont@free.fr>
Mon, 24 Aug 2009 15:36:00 +0000 (17:36 +0200)
projects/macosx/framework/Headers/Internal/VLCLibVLCBridging.h
projects/macosx/framework/Headers/Public/VLCKit.h
projects/macosx/framework/Headers/Public/VLCMediaListPlayer.h [new file with mode: 0644]
projects/macosx/framework/Sources/VLCMediaListPlayer.m [new file with mode: 0644]
projects/macosx/framework/Sources/VLCMediaPlayer.m
projects/macosx/framework/VLCKit.xcodeproj/project.pbxproj

index 8b3cd75..8125d10 100644 (file)
@@ -25,6 +25,7 @@
 #import "VLCLibrary.h"
 #import "VLCMediaListAspect.h"
 #import "VLCStreamOutput.h"
+#import "VLCMediaPlayer.h"
 
 /* Utility functions */
 /**
@@ -93,6 +94,15 @@ extern void __catch_exception( void * e, const char * function, const char * fil
 /**
  * Bridges functionality between VLCMedia and VLCMediaPlayer
  */
+@interface VLCMediaPlayer (LibVLCBridging)
+
+/* Properties */
+@property (readonly) void * libVLCMediaPlayer;    //< LibVLC media list pointer.
+@end
+
+/**
+ * Bridges functionality between VLCMediaPlayer and LibVLC core
+ */
 @interface VLCMedia (VLCMediaPlayerBridging)
 /**
  * Set's the length of the media object.  This value becomes available once the
index 868aeec..5cfdabc 100644 (file)
  *****************************************************************************/
 
 /**
- * TODO: Framework Documetnation
+ * TODO: Framework Documentation
  */
 
 #import <VLCKit/VLCLibrary.h>
 #import <VLCKit/VLCMedia.h>
 #import <VLCKit/VLCMediaLibrary.h>
 #import <VLCKit/VLCMediaList.h>
+#import <VLCKit/VLCMediaListPlayer.h>
 #import <VLCKit/VLCMediaListAspect.h>
 #import <VLCKit/VLCMediaDiscoverer.h>
 #import <VLCKit/VLCMediaPlayer.h>
diff --git a/projects/macosx/framework/Headers/Public/VLCMediaListPlayer.h b/projects/macosx/framework/Headers/Public/VLCMediaListPlayer.h
new file mode 100644 (file)
index 0000000..bdc9c65
--- /dev/null
@@ -0,0 +1,35 @@
+//
+//  VLCMediaListPlayer.h
+//  VLCKit
+//
+//  Created by Pierre d'Herbemont on 8/24/09.
+//  Copyright 2009 __MyCompanyName__. All rights reserved.
+//
+
+@class VLCMedia, VLCMediaPlayer, VLCMediaList;
+
+@interface VLCMediaListPlayer : NSObject {
+    void *instance;
+    VLCMedia *_rootMedia;
+    VLCMediaPlayer *_mediaPlayer;
+    VLCMediaList *_mediaList;
+}
+
+@property (readwrite, retain) VLCMediaList *mediaList;
+
+/**
+ * rootMedia - Use this method to play a media and its subitems.
+ * This will erase mediaList.
+ * Setting mediaList will erase rootMedia.
+ */
+@property (readwrite, retain) VLCMedia *rootMedia;
+@property (readonly, retain) VLCMediaPlayer *mediaPlayer;
+
+
+/**
+ * Basic play and stop are here. For other method, use the mediaPlayer.
+ * This may change.
+ */
+- (void)play;
+- (void)stop;
+@end
diff --git a/projects/macosx/framework/Sources/VLCMediaListPlayer.m b/projects/macosx/framework/Sources/VLCMediaListPlayer.m
new file mode 100644 (file)
index 0000000..b35855e
--- /dev/null
@@ -0,0 +1,98 @@
+//
+//  VLCMediaListPlayer.m
+//  VLCKit
+//
+//  Created by Pierre d'Herbemont on 8/24/09.
+//  Copyright 2009 __MyCompanyName__. All rights reserved.
+//
+
+#import "VLCMediaListPlayer.h"
+#import "VLCMedia.h"
+#import "VLCMediaPlayer.h"
+#import "VLCMediaList.h"
+#import "VLCLibVLCBridging.h"
+
+@implementation VLCMediaListPlayer
+- (id)init
+{
+    if (self = [super init])
+    {
+        _mediaPlayer = [[VLCMediaPlayer alloc] init];
+
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+        instance = libvlc_media_list_player_new([VLCLibrary sharedInstance], &ex);
+        catch_exception(&ex);
+        libvlc_media_list_player_set_media_player(instance, [_mediaPlayer libVLCMediaPlayer], &ex);
+        catch_exception(&ex);
+    }
+    return self;
+}
+
+- (void)dealloc
+{
+    [_mediaPlayer release];
+    [_rootMedia release];
+    [super dealloc];
+}
+- (VLCMediaPlayer *)mediaPlayer
+{
+    return _mediaPlayer;
+}
+
+- (void)setMediaList:(VLCMediaList *)mediaList
+{
+    if (_mediaList == mediaList)
+        return;
+    [_mediaList release];
+    _mediaList = [mediaList retain];
+    
+    libvlc_exception_t ex;
+    libvlc_exception_init(&ex);
+    libvlc_media_list_player_set_media_list(instance, [mediaList libVLCMediaList], &ex);
+    catch_exception(&ex);
+    [self willChangeValueForKey:@"rootMedia"];
+    [_rootMedia release];
+    _rootMedia = nil;
+    [self didChangeValueForKey:@"rootMedia"];
+}
+
+- (VLCMediaList *)mediaList
+{
+    return _mediaList;
+}
+
+- (void)setRootMedia:(VLCMedia *)media
+{
+    if (_rootMedia == media)
+        return;
+    [_rootMedia release];
+    _rootMedia = [media retain];
+    VLCMediaList *mediaList = [[VLCMediaList alloc] init];
+    if (media)
+        [mediaList addMedia:media];
+    [self setMediaList:mediaList];
+    [mediaList release];
+}
+
+- (VLCMedia *)rootMedia
+{
+    return _rootMedia;
+}
+
+- (void)play
+{
+    libvlc_exception_t ex;
+    libvlc_exception_init(&ex);
+    libvlc_media_list_player_play(instance, &ex);
+    catch_exception(&ex);    
+}
+
+- (void)stop
+{
+    libvlc_exception_t ex;
+    libvlc_exception_init(&ex);
+    libvlc_media_list_player_stop(instance, &ex);
+    catch_exception(&ex);        
+}
+@end
index 6f781da..73b7208 100644 (file)
@@ -600,7 +600,10 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
     return ret;
 }
 
-
+- (void *)libVLCMediaPlayer
+{
+    return instance;
+}
 @end
 
 @implementation VLCMediaPlayer (Private)
index 9e33155..97b395b 100644 (file)
@@ -48,6 +48,8 @@
 /* End PBXAggregateTarget section */
 
 /* Begin PBXBuildFile section */
+               63014A7A1042ACE100534090 /* VLCMediaListPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 63014A781042ACE100534090 /* VLCMediaListPlayer.m */; };
+               63014B7E1042E64A00534090 /* VLCMediaListPlayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 63014B7D1042E64A00534090 /* VLCMediaListPlayer.h */; };
                6303C43A0CF45CAE0000ECC8 /* VLCMediaListAspect.m in Sources */ = {isa = PBXBuildFile; fileRef = 6303C4390CF45CAE0000ECC8 /* VLCMediaListAspect.m */; };
                6303C43C0CF45CC30000ECC8 /* VLCMediaListAspect.h in Headers */ = {isa = PBXBuildFile; fileRef = 6303C43B0CF45CC30000ECC8 /* VLCMediaListAspect.h */; settings = {ATTRIBUTES = (Public, ); }; };
                632A0E850D3835C400AFC99B /* VLCStreamSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 632A0E830D3835C400AFC99B /* VLCStreamSession.h */; settings = {ATTRIBUTES = (Public, ); }; };
                0867D6A5FE840307C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
                1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
                32DBCF5E0370ADEE00C91783 /* VLC_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLC_Prefix.pch; sourceTree = "<group>"; };
+               63014A781042ACE100534090 /* VLCMediaListPlayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCMediaListPlayer.m; sourceTree = "<group>"; };
+               63014B7D1042E64A00534090 /* VLCMediaListPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCMediaListPlayer.h; path = Public/VLCMediaListPlayer.h; sourceTree = "<group>"; };
                63030CC70CCA652C0088ECD1 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.xml; name = Info.plist; path = Resources/Info.plist; sourceTree = "<group>"; };
                6303C4390CF45CAE0000ECC8 /* VLCMediaListAspect.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCMediaListAspect.m; sourceTree = "<group>"; };
                6303C43B0CF45CC30000ECC8 /* VLCMediaListAspect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCMediaListAspect.h; path = Public/VLCMediaListAspect.h; sourceTree = "<group>"; };
                                EF78BD3E0CAEEFF600354E6E /* VLCMedia.m */,
                                637D5ADB0CF6F2720073EA45 /* VLCMediaDiscoverer.m */,
                                EF78BD410CAEEFF600354E6E /* VLCMediaList.m */,
+                               63014A781042ACE100534090 /* VLCMediaListPlayer.m */,
                                6303C4390CF45CAE0000ECC8 /* VLCMediaListAspect.m */,
                                EF8BB8CF0CAFA8D80038A613 /* VLCMediaPlayer.m */,
                                EF78BD400CAEEFF600354E6E /* VLCMediaLibrary.m */,
                                637D5ABC0CF6F2650073EA45 /* VLCMediaDiscoverer.h */,
                                EF78BD160CAEEEE700354E6E /* VLCMediaList.h */,
                                6303C43B0CF45CC30000ECC8 /* VLCMediaListAspect.h */,
+                               63014B7D1042E64A00534090 /* VLCMediaListPlayer.h */,
                                EF8BB8CE0CAFA8D80038A613 /* VLCMediaPlayer.h */,
                                EF78BD150CAEEEE700354E6E /* VLCMediaLibrary.h */,
                                6341FCAE0D2C0929002A97B7 /* VLCVideoLayer.h */,
                                A7A0CEA40D2EF13000F2C039 /* VLCVideoCommon.h in Headers */,
                                632A0E850D3835C400AFC99B /* VLCStreamSession.h in Headers */,
                                632A0EC30D38392E00AFC99B /* VLCStreamOutput.h in Headers */,
+                               63014B7E1042E64A00534090 /* VLCMediaListPlayer.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                A7A0CEA50D2EF13000F2C039 /* VLCVideoCommon.m in Sources */,
                                632A0E860D3835C400AFC99B /* VLCStreamSession.m in Sources */,
                                632A0EC40D38392E00AFC99B /* VLCStreamOutput.m in Sources */,
+                               63014A7A1042ACE100534090 /* VLCMediaListPlayer.m in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };