Tag: mpmediaitem

在iOS命令中心中播放/暂停和已用时间没有正确更新

我有一个video播放器,可以从iOS的指挥中心和locking屏幕播放。 当我在我的应用中切换播放/暂停button时,它应该通过更新nowPlayingInfo ( MPNowPlayingInfoCenter )来更新命令中心( MPRemoteCommandCenter )中的播放/暂停button。 我不知道为什么它没有更新。 例如,如果我在应用程序中使用自定义button暂停video,则命令中心仍显示暂停button(表示video仍在播放,这是错误的)。 这是我如何更新nowPlayingInfo : func updateMPNowPlayingInforCenterMetadata() { guard video != nil else { nowPlayingInfoCenter.nowPlayingInfo = nil return } var nowPlayingInfo = nowPlayingInfoCenter.nowPlayingInfo ?? [String: Any]() let image: UIImage if let placeholderLocalURL = video.placeholderLocalURL, let placeholderImage = UIImage(contentsOfFile: placeholderLocalURL.path) { image = placeholderImage } else { image = UIImage() […]

从iOS库中select音乐并发送/保存

我有一个关于音乐文件的查询。 我想从iPhone / iTouch / iPad的音乐库中select1个/多个音乐文件,并保存在我的文档文件夹中或发送到服务器。 我大致通过MPMediaPickerController和AddMusic(示例代码) 。 但是,我只能得到select歌曲和播放的细节。 是否可以保存这些选定的歌曲 ,我也可以用来发送到服务器? 谢谢

在iTunes中可以使用封面时,MPMediaItemArtwork为空

UIImage “图片”始终是空的(“空”),虽然封面显示在音乐应用程序由苹果。 在iOS 7中,它工作正常,但与iOS 8我没有掩护。 我的代码有什么问题,或iOS 8中发生了什么变化? -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { AlbumCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AlbumCell"]; MPMediaItemCollection *song = self.songsList[indexPath.row]; cell.albumName.text = [[song representativeItem] valueForProperty: MPMediaItemPropertyAlbumTitle]; cell.albumArtist.text = [[song representativeItem] valueForProperty:MPMediaItemPropertyAlbumArtist]; CGSize artworkImageViewSize = CGSizeMake(100, 100); MPMediaItemArtwork *artwork = [song valueForProperty:MPMediaItemPropertyArtwork]; UIImage *image = [artwork imageWithSize:artworkImageViewSize]; NSLog(@"——————-"); NSLog(@"%@",[[song representativeItem] valueForProperty: MPMediaItemPropertyAlbumTitle]); NSLog(@"%@",image); if […]

MPMediaQuerysearch艺术家,专辑和歌曲

如何以与iOS音乐应用程序相同的方式searchiPod库? 我想进行一般查询,返回每个艺术家,专辑和歌曲的结果。 例如,如果我searchKenny Chesney,我希望歌曲查询返回所有Kenny Chesney歌曲(以及任何包含Kenny Chesney的歌曲标题或专辑)。当我为每个属性(歌曲标题,专辑标题,艺术家的名字),一个空数组返回。 下面是一些代码,可以让你更好地了解我正在尝试完成的任务: MPMediaPropertyPredicate *songPredicate = [MPMediaPropertyPredicate predicateWithValue:searchText forProperty:MPMediaItemPropertyTitle comparisonType:MPMediaPredicateComparisonContains]; MPMediaPropertyPredicate *albumPredicate = [MPMediaPropertyPredicate predicateWithValue:searchText forProperty:MPMediaItemPropertyAlbumTitle comparisonType:MPMediaPredicateComparisonContains]; MPMediaPropertyPredicate *artistPredicate = [MPMediaPropertyPredicate predicateWithValue:searchText forProperty:MPMediaItemPropertyArtist comparisonType:MPMediaPredicateComparisonContains]; MPMediaQuery *songsQuery = [MPMediaQuery songsQuery]; [songsQuery addFilterPredicate:songNamePredicate]; [songsQuery addFilterPredicate:artistNamePredicate]; [songsQuery addFilterPredicate:albumNamePredicate]; NSLog(@"%@", [songsQuery items]); 我有这个工作,通过与每个谓词分别运行查询,但这似乎是非常低效的!