开发者

ImageWithSize on MPMediaItemArtwork returns very small coverart image (55 x 55 px)

I am tryi开发者_JAVA技巧ng to create a very simple music player (for small children) in Monotouch and have most of it working just great.

However when I iterate through MPMediaItems in a playlist and try to get their artwork I always get an image with size 55 x 55 pixels. When I listen to the songs in the builtin IPod application I can see that the stored artwork is larger than that.

Platform: Latest monodevelop and monotouch. iOS 4.2.3 on device

Code to get artwork of the first song in a playlist:

MPMediaItem[] songs = foundPlaylist.Items;
MPMediaItemArtwork artwork = (MPMediaItemArtwork)songs[0].ValueForProperty(MPMediaItemProperty.Artwork);
var imageRect = artwork.ImageCropRectangle;
UIImage artWorkImage = artwork.ImageWithSize (imageRect);

Am pretty stumped here. Any ideas?

Best regards

Soren


Oki, got it figured out. Big thanks to Kangaroo on the monotouch chat!

There is a binding error in the imageWithSize method on MPMediaItemArtwork, so you need to message the selector directly. This is done in this way (to get a 256x256 image):

UIImage artWorkImage = (UIImage) Runtime.GetNSObject (Messaging.IntPtr_objc_msgSend_SizeF (artwork.Handle, Selector.GetHandle ("imageWithSize:"), new SizeF (256, 256)));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜