3

抓取当前歌曲的专辑封面并使用它来更改某个会imageView.image产生错误,但不再崩溃。(以前是这样,因为我忽略了if (!artwork)错误处理。嗯。)

这种方法:

- (void)handleNowPlayingItemChanged:(id)notification {
    MPMediaItem *item = self.musicPlayer.nowPlayingItem;
    CGSize albumCoverSize = self.albumCover.bounds.size;
    MPMediaItemArtwork *artwork =
                            [item valueForProperty:MPMediaItemPropertyArtwork];
    if (artwork) {
        self.albumCover.image = [artwork imageWithSize:albumCoverSize];
    } else {
        self.albumCover.image = nil;
    }
}

爆发是这样的:

CPSqliteStatementPerform: attempt to write a readonly database for
    UPDATE ddd.ext_container SET orig_date_modified = (SELECT date_modified
    FROM container WHERE pid=container_pid) WHERE orig_date_modified=0
CPSqliteStatementReset: attempt to write a readonly database for
    UPDATE ddd.ext_container SET orig_date_modified = (SELECT date_modified
    FROM container WHERE pid=container_pid) WHERE orig_date_modified=0

但仅在发射时。它仍然显示图像(或缺少图像)。奇怪的。

编辑: iPod 库是只读的(应用程序不能改变任何东西,只有 iTunes),所以它可能因为
我写了只读的东西而对我大喊大叫,但仍然允许它,因为没有任何只读被修改?

在修复之后,我需要调整大小(用于景观支持)而不是 IB 的拉伸。
不是很重要,但仍然是一件好事。

4

2 回答 2

0

这就是我所做的。它不会产生错误,并且每次都会生成图像。如果歌曲没有图像,则默认为我提供的图像。我认为因为您没有检查具有特定尺寸(320 x 320,与我的屏幕宽度匹配)的图像,所以它无法正确计算出来。我不知道你为什么会收到 SQLite 错误,但希望这能解决它!

MPMediaItemArtwork *artworkItem = [self.musicPlayer.nowPlayingItem valueForProperty: MPMediaItemPropertyArtwork];
if ([artworkItem imageWithSize:CGSizeMake(320, 320)]) {
    [self.currentlyPlayingArtworkView setImage:[artworkItem imageWithSize:CGSizeMake (320, 320)]];
}
else {
    [self.currentlyPlayingArtworkView setImage:[UIImage imageNamed:@"NoArtworkImage"]];
}
于 2012-03-04T07:49:16.790 回答
0

链接在这里 -为什么我在 xcode 控制台中收到这个 CPSqliteStatementPerform 错误

将其放在这里,以便可以将问题标记为已回答。

于 2012-04-02T18:35:59.690 回答