Commit 3c5a53bc authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

MacOSX/Framework/VLCMediaList.m: Fix a few warnings and use a Dictionary...

MacOSX/Framework/VLCMediaList.m: Fix a few warnings and use a Dictionary instead of an array for -mediaListItemAdded: argument.
parent cbe148f2
...@@ -33,15 +33,15 @@ extern NSString * VLCMediaListItemDeleted; ...@@ -33,15 +33,15 @@ extern NSString * VLCMediaListItemDeleted;
// TODO: Documentation // TODO: Documentation
@protocol VLCMediaListDelegate @protocol VLCMediaListDelegate
- (void)mediaList:(VLCMediaList *) mediaAdded:(VLCMedia *)media atIndex:(int)index; - (void)mediaList:(VLCMediaList *)aMediaList mediaAdded:(VLCMedia *)media atIndex:(int)index;
- (void)mediaList:(VLCMediaList *) mediaRemovedAtIndex:(int)index; - (void)mediaList:(VLCMediaList *)aMediaList mediaRemovedAtIndex:(int)index;
@end @end
// TODO: Documentation // TODO: Documentation
@interface VLCMediaList : NSObject @interface VLCMediaList : NSObject
{ {
void * p_mlist; //< Internal instance of media list void * p_mlist; //< Internal instance of media list
id delegate; //< Delegate object id <VLCMediaListDelegate,NSObject> delegate; //< Delegate object
} }
/* Properties */ /* Properties */
......
...@@ -39,7 +39,7 @@ NSString *VLCMediaListItemDeleted = @"VLCMediaListItemDeleted"; ...@@ -39,7 +39,7 @@ NSString *VLCMediaListItemDeleted = @"VLCMediaListItemDeleted";
- (void)initInternalMediaList; - (void)initInternalMediaList;
/* Libvlc event bridges */ /* Libvlc event bridges */
- (void)mediaListItemAdded:(NSArray *)args; - (void)mediaListItemAdded:(NSDictionary *)args;
- (void)mediaListItemRemoved:(NSNumber *)index; - (void)mediaListItemRemoved:(NSNumber *)index;
@end @end
...@@ -53,8 +53,10 @@ static void HandleMediaListItemAdded(const libvlc_event_t *event, void *user_dat ...@@ -53,8 +53,10 @@ static void HandleMediaListItemAdded(const libvlc_event_t *event, void *user_dat
// been added // been added
[[VLCEventManager sharedManager] callOnMainThreadObject:self [[VLCEventManager sharedManager] callOnMainThreadObject:self
withMethod:@selector(mediaListItemAdded:) withMethod:@selector(mediaListItemAdded:)
withArgumentAsObject:[NSArray arrayWithObjects:[VLCMedia mediaWithLibVLCMediaDescriptor:event->u.media_list_item_added.item], withArgumentAsObject:[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:event->u.media_list_item_added.index], nil]]; [VLCMedia mediaWithLibVLCMediaDescriptor:event->u.media_list_item_added.item], @"media",
[NSNumber numberWithInt:event->u.media_list_item_added.index], @"index",
nil]];
} }
static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * user_data) static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * user_data)
...@@ -283,22 +285,16 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use ...@@ -283,22 +285,16 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
quit_on_exception( &p_e ); quit_on_exception( &p_e );
} }
- (void)mediaListItemAdded:(NSArray *)args - (void)mediaListItemAdded:(NSDictionary *)args
{ {
VLCMedia *media = [args objectAtIndex:0];
NSNumber *index = [args objectAtIndex:1];
// Post the notification // Post the notification
[[NSNotificationCenter defaultCenter] postNotificationName:VLCMediaListItemAdded [[NSNotificationCenter defaultCenter] postNotificationName:VLCMediaListItemAdded
object:self object:self
userInfo:[NSDictionary dictionaryWithObjectsAndKeys: userInfo:args];
media, @"media",
index, @"index",
nil]];
// Let the delegate know that the item was added // Let the delegate know that the item was added
if (delegate && [delegate respondsToSelector:@selector(mediaList:mediaAdded:atIndex:)]) if (delegate && [delegate respondsToSelector:@selector(mediaList:mediaAdded:atIndex:)])
[delegate mediaList:self mediaAdded:media atIndex:[index intValue]]; [delegate mediaList:self mediaAdded:[args objectForKey:@"media"] atIndex:[[args objectForKey:@"index"] intValue]];
} }
- (void)mediaListItemRemoved:(NSNumber *)index - (void)mediaListItemRemoved:(NSNumber *)index
...@@ -312,7 +308,7 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use ...@@ -312,7 +308,7 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
// Let the delegate know that the item is being removed // Let the delegate know that the item is being removed
if (delegate && [delegate respondsToSelector:@selector(mediaList:mediaRemovedAtIndex:)]) if (delegate && [delegate respondsToSelector:@selector(mediaList:mediaRemovedAtIndex:)])
[delegate mediaList:self mediaRemovedAtIndex:index]; [delegate mediaList:self mediaRemovedAtIndex:[index intValue]];
} }
@end @end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment