标签: mpmediaitemcollection

如何从 MPMediaItemCollection 获取图稿

我的目标是获取 iPod 库中播放列表的封面图片。我做了类似的事情

 playlistMediaItemCollections = MPMediaQuery.playlistsQuery().collections ?? []
 let artworks = playlistMediaItemCollections.map { $0.valueForKey(MPMediaItemPropertyArtwork) as? MPMediaItemArtwork }
Run Code Online (Sandbox Code Playgroud)

但它导致错误

 Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<MPConcreteMediaPlaylist 0x1468b1eb0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key artwork.'
Run Code Online (Sandbox Code Playgroud)

任何人都知道我如何获得播放列表艺术品?谢谢

mpmediaitemcollection mpmediaquery ios mpmedialibrary swift

3
推荐指数
1
解决办法
1071
查看次数

从iOS媒体库中获取所有艺术家的列表

我希望在用户的库中获取一个MPMediaItemCollectionNSArray所有艺术家.这是我当前的代码(显然不起作用):

- (void)viewDidLoad
{
    [super viewDidLoad];
    MPMediaQuery *artistsQuery = [MPMediaQuery artistsQuery];
    self.artistsArray = artistsQuery.collections;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.artistsArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ArtistsCell"];
    cell.textLabel.text = [(MPMediaItemCollection *)self.artistsArray[indexPath.row]   valueForProperty:MPMediaPlaylistPropertyName];
    NSLog(@"%@", cell.textLabel.text);
    return cell;
}
Run Code Online (Sandbox Code Playgroud)

mpmediaitemcollection mpmusicplayercontroller ios

2
推荐指数
1
解决办法
945
查看次数

在AVPlayer [Swift]中播放MPMediaItemCollection中的项目

这是事情,我有一个MPMediaItemCollection与用户选择项目(从库).我使用mediaPicker来做到这一点.现在,我需要从这些项目中获取URL,以便我可以在AVPlayer上播放它们.这是我能找到的最好的,但是当我"翻译"为快速时,它会变得混乱.如果有人可以帮助我,我会非常感激.

mpmediaitemcollection avplayer swift

2
推荐指数
1
解决办法
1911
查看次数

MPMusicPlayerController队列问题

我的MPMusicPlayerController存在一些问题.这是一个iPodMusicPlayer,而不是appmusicplayer.我的问题是我无法让队列以正确的顺序播放.让我进一步解释一下:

我使用iPod选择器来选择媒体集合,然后将其添加到音乐播放器的队列中.一旦我这样做,我在表格视图中显示集合中的项目.然后,用户可以"播放"此队列.但是,出于某种原因,当我尝试使用ipod控件导航到播放列表时,队列看起来像是错误的顺序.这是一些代码:

媒体选择器调用此方法:

-(void)updatePlayerQueueWithMediaCollection:(MPMediaItemCollection *)collection {

if (collection) {

    // If there's no playback queue yet...

    if (self.userMediaItemCollection == nil) {
        [self setUserMediaItemCollection: collection];
        [self.musicPlayer setQueueWithItemCollection:self.userMediaItemCollection];
    } else {
        BOOL wasPlaying = NO;
        if (self.musicPlayer.playbackState == MPMusicPlaybackStatePlaying) {
            wasPlaying = YES;
        }

        // Save the now-playing item and its current playback time.

        MPMediaItem *nowPlayingItem        = self.musicPlayer.nowPlayingItem;
        NSTimeInterval currentPlaybackTime = self.musicPlayer.currentPlaybackTime;

        // Combine the previously-existing media item collection with the new one

        NSMutableArray *combinedMediaItems =
        [[self.userMediaItemCollection items] mutableCopy];
        NSArray *newMediaItems = …
Run Code Online (Sandbox Code Playgroud)

mpmediaitemcollection ios mpmediaplayercontroller

1
推荐指数
1
解决办法
2727
查看次数

调用NSString whit多个参数

我是初学者,也许这是一个微不足道的问题.我有这个方法:

-(NSString *)getInfoFormediaItem:(MPMediaItemCollection *)list {    
NSString *trackCount;

if ([list count] > 0) {
    trackCount = [NSString stringWithFormat:NSLocalizedString(@"%lu Songs", @""), (unsigned long)[list count]];
} else if([list count] == 1) {
    trackCount = [NSString stringWithFormat:NSLocalizedString(@"1 Song", @"")];
} else {
    trackCount = [NSString stringWithFormat:NSLocalizedString(@"0 Song", @"") ];
}

return [NSString stringWithFormat:@"%@", trackCount];
}
Run Code Online (Sandbox Code Playgroud)

我想在这里用MPMediaItemCollection调用它:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];

if( cell == nil )
{
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
} 

MPMediaQuery …
Run Code Online (Sandbox Code Playgroud)

objective-c nsstring mpmediaitemcollection ios

0
推荐指数
1
解决办法
56
查看次数