获取当前歌曲的插图时出错
抓取当前歌曲的专辑封面并使用它来更改某个 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 的拉伸。
虽然不是很重要,但仍然是一件好事。
Grabbing album art for current song and using it to change a certain imageView.image
generates an error, but no longer crashes. (It did before because I left out the if (!artwork)
error handling. Eheh.)
This method:
- (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;
}
}
Explodes like this:
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
But only on launch. And it still shows the image (or lack thereof). Weird.
Edit: The iPod Library is readonly (apps can't change anything, only iTunes), so maybe it's yelling at
me for writing a readonly something, but still allowing it because nothing readonly is being modified?
And after that's fixed, I need to get resizing working (for Landscape support) instead of IB's stretching.
Not vital, but still a nice thing to have.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是我所做的。它不会产生错误,并且每次都会生成图像。如果歌曲没有图片,则默认为我提供的图片。我认为因为您没有检查特定尺寸的图像(320 x 320,与我的屏幕宽度匹配),所以它无法正确计算出来。我不知道为什么你会收到 SQLite 错误,但希望这可以解决它!
Here's what I do. It creates no errors, and produces an image every time. If the song doesn't have an image, it defaults to the one I provide. I think because you're not checking for an image with a specific size (320 by 320, matching the screen width for me), it fails to figure it out correctly. I don't know why you're getting the SQLite error, but hopefully this fixes it!
链接在这里 - 为什么我会得到这个xcode 控制台中的 CPSqliteStatementPerform 错误
将其放在这里,以便可以将问题标记为已回答。
Link here - Why am I getting this CPSqliteStatementPerform error in xcode console
Putting this here so the question can be marked as Answered.