Error getting artwork for current song
Asked Answered
S

2

3

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.

Shrovetide answered 14/6, 2011 at 15:29 Comment(5)
Are you using a SQLite database? How do you get its path?Besides
Not so much as a single line of SQLite in my code, but I don't know what's going on behind the scenes. Clearly something to do with a database. (Presumably the library used by the iPod app.) // I'm not getting the specific path. Instead, I take the nowPlayingItem and get properties from that.Shrovetide
I have this warning too, I have never figured out how to supress it, as I'm not doing any writing at all, I'm just getting information from the iPod library. I'm interested to see if anyone answers this.Lipo
Since this happened in old Xcode/iOS versions (still no idea how), should the question be deleted?Shrovetide
Answered here - #5944781Shrovetide
S
0

Link here - Why am I getting this CPSqliteStatementPerform error in xcode console

Putting this here so the question can be marked as Answered.

Shrovetide answered 2/4, 2012 at 18:35 Comment(0)
S
0

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!

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"]];
}
Sullyprudhomme answered 4/3, 2012 at 7:49 Comment(1)
Just threw a search at Google since this question appeared in my profile again. According to the accepted answer for this question, it was just a bug. 10 months ago.Shrovetide
S
0

Link here - Why am I getting this CPSqliteStatementPerform error in xcode console

Putting this here so the question can be marked as Answered.

Shrovetide answered 2/4, 2012 at 18:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.