简体   繁体   English

如何获取iphone ipod播放列表图像并在图像视图中显示它

[英]how to get iphone ipod playlist images and display it in image view

I am working with iphone ipod to read the album and playlist and play it in my application. 我正在使用iphone ipod阅读专辑和播放列表并在我的应用程序中播放。

My question is that that i get the image from the album i have selected. 我的问题是,我从我选择的专辑中获取了图像。 and it is also working well in my application. 它在我的应用程序中也运行良好。

But i never get images from the playlist which i have selected their are different songs in my playlist and also having different image for that songs. 但我从来没有从播放列表中获取图像,我在播放列表中选择了不同的歌曲,并且还有不同的歌曲图像。 for the album i have get the code and it work great. 对于专辑我已经获得了代码,它工作得很好。 i am new for this and i cant found any reference code for this. 我是新手,我无法找到任何参考代码。

And i am using AVPlayer to play the songs. 我正在使用AVPlayer播放歌曲。

So please help me and provide some sample code. 所以请帮助我并提供一些示例代码。 for how to get all images from playlist and convert that image to data in iphone. 如何从播放列表中获取所有图像并将该图像转换为iPhone中的数据。

Please help me. 请帮我。

You're looking for is the MPMediaItemPropertyArtwork for MPMediaItem . 您正在寻找的是MPMediaItemPropertyArtworkMPMediaItem As stated in the docs. 正如文档中所述。 After getting the artwork property you can make a MPMediaItemArtwork object, as stated in the docs. 获取图稿属性后,您可以制作MPMediaItemArtwork对象,如文档中所述。

An MPMediaItemArtwork object, or media item artwork, represents a graphical image, such as music album cover art, associated with a media item. MPMediaItemArtwork对象或媒体项目图片表示与媒体项目相关联的图形图像,例如音乐专辑封面艺术。 Media items are described in MPMediaItem Class Reference. 媒体项目在MPMediaItem类参考中描述。

With this you can do something like this. 有了这个,你可以做这样的事情。 Assuming song is an MPMediaItem : 假设songMPMediaItem

UIImage *image = nil;

MPMediaItemArtwork *itemArtwork = [song valueForProperty:
                                          MPMediaItemPropertyArtwork];
if(itemArtwork != nil)
     image = [itemArtwork imageWithSize:CGSizeMake(100,100)];

Now you have image containing your MPMediaItem artwork, set it to your image view ( [myImageView setImage:image] ). 现在您有包含MPMediaItem图稿的image ,将其设置为图像视图( [myImageView setImage:image] )。 Keep in mind, this will only work if artwork IS available. 请记住,这只会工作,如果艺术品可用的。

Hope this helps. 希望这可以帮助。

您可以使用VTM_AViPodReader演示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM