]> git.sesse.net Git - vlc/commitdiff
MacOSX/Framework/Examples/test/Controller.m: Updated example to comply with latest...
authorFaustino Osuna <riquedafreak@videolan.org>
Thu, 3 Jan 2008 20:44:36 +0000 (20:44 +0000)
committerFaustino Osuna <riquedafreak@videolan.org>
Thu, 3 Jan 2008 20:44:36 +0000 (20:44 +0000)
extras/MacOSX/Framework/Examples/test/Controller.m

index 04f353a9bc79dd0b65e9cacdcab19e01e85fec78..4f88d6d22a79dca16c227889b5ee72d7a25bdf2c 100644 (file)
@@ -22,7 +22,7 @@ static void *sleepForMe(void)
     [videoView setAutoresizingMask: NSViewHeightSizable|NSViewWidthSizable];
 
     playlist = [[VLCMediaList alloc] init];
-    [playlist setDelegate:self];
+    [playlist addObserver:self forKeyPath:@"media" options:NSKeyValueObservingOptionNew context:nil];
     
     player = [[VLCMediaPlayer alloc] initWithVideoView:videoView];
     mediaIndex = -1;
@@ -37,6 +37,8 @@ static void *sleepForMe(void)
 
 - (void)applicationWillTerminate:(NSNotification *)aNotification
 {
+    [playlist removeObserver:self forKeyPath:@"media"];
+    
     [player pause];
     [player setMedia:nil];
     [player release];
@@ -44,7 +46,6 @@ static void *sleepForMe(void)
     [videoView release];
 }
 
-
 - (void)changeAndPlay:(id)sender
 {
     if ([playlistOutline selectedRow] != mediaIndex)
@@ -82,15 +83,11 @@ static void *sleepForMe(void)
     [player pause];
 }
 
-//
-- (void)mediaList:(VLCMediaList *)mediaList mediaAdded:(VLCMedia *)media atIndex:(int)index
-{
-    [playlistOutline reloadData];
-}
-
-- (void)mediaList:(VLCMediaList *)mediaList mediaRemoved:(VLCMedia *)media atIndex:(int)index
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
 {
-    [playlistOutline reloadData];
+    if ([keyPath isEqualToString:@"media"] && object == playlist) {
+        [playlistOutline reloadData];
+    }
 }
 
 // NSTableView Implementation
@@ -102,7 +99,7 @@ static void *sleepForMe(void)
 - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn
                        row:(int)row
 {
-    return [[playlist mediaAtIndex:row] description];
+    return [(VLCMedia *)[playlist mediaAtIndex:row].metaDictionary valueForKey:VLCMetaInformationTitle];
 }
 
 - (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id <NSDraggingInfo>)info