X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=extras%2FMacOSX%2FFramework%2FExamples%2Ftest%2FController.m;fp=extras%2FMacOSX%2FFramework%2FExamples%2Ftest%2FController.m;h=4f88d6d22a79dca16c227889b5ee72d7a25bdf2c;hb=0b300bd167e891200f54e007562e9a7fc92714ea;hp=04f353a9bc79dd0b65e9cacdcab19e01e85fec78;hpb=45400df94e94432062cbf8c7f3c57ea3d3889db6;p=vlc diff --git a/extras/MacOSX/Framework/Examples/test/Controller.m b/extras/MacOSX/Framework/Examples/test/Controller.m index 04f353a9bc..4f88d6d22a 100644 --- a/extras/MacOSX/Framework/Examples/test/Controller.m +++ b/extras/MacOSX/Framework/Examples/test/Controller.m @@ -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 )info