alternativa , un brutto scherzo che funziona Per me (tm).
- (MPMediaItem *)getMediaItemForURL:(NSURL *)url {
// We're going to assume that the last query value in the URL is the media item's persistent ID and query off that.
NSString *queryString = [url query];
if (queryString == nil) // shouldn't happen
return nil;
NSArray *components = [queryString componentsSeparatedByString:@"="];
if ([components count] < 2) // also shouldn't happen
return nil;
id trackId = [components objectAtIndex:1];
MPMediaQuery *query = [[MPMediaQuery alloc] init];
[query addFilterPredicate:[MPMediaPropertyPredicate predicateWithValue:trackId forProperty:MPMediaItemPropertyPersistentID]];
NSArray *items = [query items];
if ([items count] < 1) // still shouldn't happen
return nil;
return [items objectAtIndex:0];
}
Commenti apprezzati per dove questo potrebbe andare storto o come migliorarlo. Preferisco passare l'URL in luogo di PersistentID in quanto ho più origini multimediali, che possono utilizzare URL. Usare PersistentID significherebbe un sacco di "se questo è un ID multimediale, fallo, altrimenti, fallo con l'URL".
fonte
2013-10-18 20:11:53
grazie del tuo aiuto, funziona :) – flatronka
Come passare l'elemento multimediale dall'host al lato client utilizzando la connettività moltiplicatore? –