Commit f02a46fd authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* Fixed Meta for OSX, so i know what music i'm listening to.

(debug left in place. when you run into a crash please not the console info so we can investigate)
parent 6f5d2c79
...@@ -150,6 +150,7 @@ ...@@ -150,6 +150,7 @@
- (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
{ {
int i_return = 0; int i_return = 0;
playlist_item_t *p_item = NULL;
playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST, playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE ); FIND_ANYWHERE );
if( p_playlist == NULL ) if( p_playlist == NULL )
...@@ -163,32 +164,29 @@ ...@@ -163,32 +164,29 @@
if( item == nil ) if( item == nil )
{ {
/* root object */ /* root object */
if( p_playlist->p_root_category ) p_item = p_playlist->p_root_category;
{
i_return = p_playlist->p_root_category->i_children;
}
} }
else else
{ {
playlist_item_t *p_item = (playlist_item_t *)[item pointerValue]; p_item = (playlist_item_t *)[item pointerValue];
}
if( p_item ) if( p_item )
i_return = p_item->i_children; i_return = p_item->i_children;
}
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
if( i_return <= 0 ) if( i_return <= 0 )
i_return = 0; i_return = 0;
NSLog( @"%d children for %s", i_return, p_item->p_input->psz_name );
return i_return; return i_return;
} }
/* return the child at index for the Obj-C pointer item */ /* DONE */ /* return the child at index for the Obj-C pointer item */ /* DONE */
- (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
{ {
playlist_item_t *p_return = NULL; playlist_item_t *p_return = NULL, *p_item = NULL;
NSValue *o_value;
playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST, playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE ); FIND_ANYWHERE );
NSValue *o_value;
if( p_playlist == NULL ) if( p_playlist == NULL )
return nil; return nil;
...@@ -196,24 +194,23 @@ ...@@ -196,24 +194,23 @@
if( item == nil ) if( item == nil )
{ {
/* root object */ /* root object */
if( p_playlist->p_root_category ) p_item = p_playlist->p_root_category;
{
p_return = p_playlist->p_root_category->pp_children[index];
}
} }
else else
{ {
playlist_item_t *p_item = (playlist_item_t *)[item pointerValue]; p_item = (playlist_item_t *)[item pointerValue];
}
if( p_item && index < p_item->i_children && index >= 0 ) if( p_item && index < p_item->i_children && index >= 0 )
p_return = p_item->pp_children[index]; p_return = p_item->pp_children[index];
}
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
o_value = [o_outline_dict objectForKey:[NSString stringWithFormat: @"%p", p_return]]; o_value = [o_outline_dict objectForKey:[NSString stringWithFormat: @"%p", p_return]];
NSLog( @"%s", p_return->p_input->psz_name);
if( o_value == nil ) if( o_value == nil )
{ {
o_value = [[NSValue valueWithPointer: p_return] retain]; o_value = [[NSValue valueWithPointer: p_return] retain];
NSLog( @"error missing value" );
} }
return o_value; return o_value;
} }
...@@ -222,7 +219,7 @@ ...@@ -222,7 +219,7 @@
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
{ {
int i_return = 0; int i_return = 0;
playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST, playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE ); FIND_ANYWHERE );
if( p_playlist == NULL ) if( p_playlist == NULL )
return NO; return NO;
...@@ -243,6 +240,7 @@ ...@@ -243,6 +240,7 @@
} }
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
NSLog( @"expandable" );
if( i_return <= 0 ) if( i_return <= 0 )
return NO; return NO;
else else
...@@ -259,20 +257,17 @@ ...@@ -259,20 +257,17 @@
if( item == nil || ![item isKindOfClass: [NSValue class]] ) return( @"error" ); if( item == nil || ![item isKindOfClass: [NSValue class]] ) return( @"error" );
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, /* Check to see if the playlist is present */
FIND_ANYWHERE ); p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( p_playlist == NULL ) if( p_playlist == NULL ) return( @"error");
{ vlc_object_release( p_playlist);
return( @"error" );
}
p_item = (playlist_item_t *)[item pointerValue]; p_item = (playlist_item_t *)[item pointerValue];
if( p_item == NULL ) if( p_item == NULL )
{ {
vlc_object_release( p_playlist );
return( @"error"); return( @"error");
} }
NSLog( @"values for %p", p_item );
if( [[o_tc identifier] isEqualToString:@"1"] ) if( [[o_tc identifier] isEqualToString:@"1"] )
{ {
...@@ -282,22 +277,14 @@ ...@@ -282,22 +277,14 @@
o_value = [NSString stringWithCString: o_value = [NSString stringWithCString:
p_item->p_input->psz_name]; p_item->p_input->psz_name];
} }
else if( [[o_tc identifier] isEqualToString:@"2"] ) else if( [[o_tc identifier] isEqualToString:@"2"] && p_item->p_input->p_meta &&
{ p_item->p_input->p_meta->psz_artist && *p_item->p_input->p_meta->psz_artist )
char *psz_temp;
psz_temp = vlc_input_item_GetInfo( p_item->p_input ,_("Meta-information"),_("Artist") );
if( psz_temp == NULL )
o_value = @"";
else
{ {
o_value = [NSString stringWithUTF8String: psz_temp]; o_value = [NSString stringWithUTF8String:
p_item->p_input->p_meta->psz_artist];
if( o_value == NULL ) if( o_value == NULL )
{ o_value = [NSString stringWithCString:
o_value = [NSString stringWithCString: psz_temp]; p_item->p_input->p_meta->psz_artist];
}
free( psz_temp );
}
} }
else if( [[o_tc identifier] isEqualToString:@"3"] ) else if( [[o_tc identifier] isEqualToString:@"3"] )
{ {
...@@ -313,7 +300,6 @@ ...@@ -313,7 +300,6 @@
o_value = @"-:--:--"; o_value = @"-:--:--";
} }
} }
vlc_object_release( p_playlist );
return( o_value ); return( o_value );
} }
...@@ -1545,7 +1531,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/ ...@@ -1545,7 +1531,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
[o_outline_dict setObject:o_value forKey:[NSString stringWithFormat:@"%p", [o_outline_dict setObject:o_value forKey:[NSString stringWithFormat:@"%p",
[o_value pointerValue]]]; [o_value pointerValue]]];
NSLog( @"add item %p", [o_value pointerValue] );
return o_value; return o_value;
} }
......
...@@ -181,7 +181,6 @@ ...@@ -181,7 +181,6 @@
/* check whether our item is valid, because we would crash if not */ /* check whether our item is valid, because we would crash if not */
if(! [self isItemInPlaylist: p_item] ) return; if(! [self isItemInPlaylist: p_item] ) return;
char *psz_temp;
vlc_mutex_lock( &p_item->p_input->lock ); vlc_mutex_lock( &p_item->p_input->lock );
/* fill uri / title / author info */ /* fill uri / title / author info */
...@@ -200,27 +199,21 @@ ...@@ -200,27 +199,21 @@
[NSString stringWithCString:p_item->p_input->psz_name] : [NSString stringWithCString:p_item->p_input->psz_name] :
[NSString stringWithUTF8String:p_item->p_input->psz_name]]; [NSString stringWithUTF8String:p_item->p_input->psz_name]];
} }
vlc_mutex_unlock( &p_item->p_input->lock );
psz_temp = vlc_input_item_GetInfo( p_item->p_input, _("Meta-information"), _("Artist") );
if( psz_temp )
{
[o_author_txt setStringValue: [NSString stringWithUTF8String: psz_temp]];
free( psz_temp );
}
/* fill the other fields */ /* fill the other fields */
[self setMeta: VLC_META_GENRE forLabel: o_genre_txt]; #define p_m p_item->p_input->p_meta
[self setMeta: VLC_META_COPYRIGHT forLabel: o_copyright_txt]; [self setMeta: p_m->psz_artist forLabel: o_author_txt];
[self setMeta: VLC_META_COLLECTION forLabel: o_collection_txt]; [self setMeta: p_m->psz_album forLabel: o_collection_txt];
[self setMeta: VLC_META_SEQ_NUM forLabel: o_seqNum_txt]; [self setMeta: p_m->psz_tracknum forLabel: o_seqNum_txt];
[self setMeta: VLC_META_DESCRIPTION forLabel: o_description_txt]; [self setMeta: p_m->psz_genre forLabel: o_genre_txt];
[self setMeta: VLC_META_RATING forLabel: o_rating_txt]; [self setMeta: p_m->psz_copyright forLabel: o_copyright_txt];
[self setMeta: VLC_META_DATE forLabel: o_date_txt]; [self setMeta: p_m->psz_rating forLabel: o_rating_txt];
[self setMeta: VLC_META_LANGUAGE forLabel: o_language_txt]; [self setMeta: p_m->psz_publisher forLabel: o_publisher_txt];
[self setMeta: VLC_META_NOW_PLAYING forLabel: o_nowPlaying_txt]; [self setMeta: p_m->psz_nowplaying forLabel: o_nowPlaying_txt];
[self setMeta: VLC_META_PUBLISHER forLabel: o_publisher_txt]; [self setMeta: p_m->psz_language forLabel: o_language_txt];
[self setMeta: p_m->psz_date forLabel: o_date_txt];
#undef p_m
vlc_mutex_unlock( &p_item->p_input->lock );
/* reload the advanced table */ /* reload the advanced table */
[[VLCInfoTreeItem rootItem] refresh]; [[VLCInfoTreeItem rootItem] refresh];
...@@ -230,12 +223,13 @@ ...@@ -230,12 +223,13 @@
[self updateStatistics: nil]; [self updateStatistics: nil];
} }
- (void)setMeta: (char *)meta forLabel: (id)theItem - (void)setMeta: (char *)psz_meta forLabel: (id)theItem
{ {
char *psz_meta = vlc_input_item_GetInfo( p_item->p_input, \
_(VLC_META_INFO_CAT), _(meta) );
if( psz_meta != NULL && *psz_meta) if( psz_meta != NULL && *psz_meta)
[theItem setStringValue: [NSString stringWithUTF8String: psz_meta]]; [theItem setStringValue:
([NSString stringWithUTF8String:psz_meta] == nil ) ?
[NSString stringWithCString:psz_meta] :
[NSString stringWithUTF8String:psz_meta]];
else else
[theItem setStringValue: @"-"]; [theItem setStringValue: @"-"];
} }
...@@ -306,8 +300,8 @@ ...@@ -306,8 +300,8 @@
p_item->p_input->psz_uri = strdup( [[o_uri_txt stringValue] UTF8String] ); p_item->p_input->psz_uri = strdup( [[o_uri_txt stringValue] UTF8String] );
p_item->p_input->psz_name = strdup( [[o_title_txt stringValue] UTF8String] ); p_item->p_input->psz_name = strdup( [[o_title_txt stringValue] UTF8String] );
vlc_meta_SetArtist( p_item->p_input->p_meta, [[o_author_txt stringValue] UTF8String] )
vlc_mutex_unlock( &p_item->p_input->lock ); vlc_mutex_unlock( &p_item->p_input->lock );
vlc_input_item_AddInfo( p_item->p_input, _("Meta-information"), _("Artist"), [[o_author_txt stringValue] UTF8String]);
val.b_bool = VLC_TRUE; val.b_bool = VLC_TRUE;
var_Set( p_playlist, "intf-change", val ); var_Set( p_playlist, "intf-change", val );
......
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