- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的应用程序显示 MPMediaPickerController
。我想保存 MediaItem
并在启动时再次播放。我认为使用 MPMediaQuery
可以做到这一点。看来,我应该使用 MPMediaItemPropertyPercientID
但我不知道如何查询它。有什么想法吗?
最佳答案
伙计,你不需要保存 mediaCollection。媒体集合它只是 MPMediaItem 对象的数组。所以你最好保存这个项目的permanentIds。这很容易
//it's how to know persistentId of the song after you got mediaItemCollection from your mediaPickerViewController
//then you can sav it in userDefaults.
- (NSNumber *)getPersistentId :(MPMediaItemCollection *)collection atIndex:(int)index {
MPMediaItem *mediaItem = [collection.items objectAtIndex:index];
NSNumber *anId = [mediaItem valueForProperty:MPMediaItemPropertyPersistentID];
return anId;
}
//when your application will be launched next time you can get required song:
- (void)obtainSongWitId:(NSNumber *)persistentId {
MPMediaQuery *query = [MPMediaQuery songsQuery];
MPMediaPropertyPredicate *predicate = [MPMediaPropertyPredicate predicateWithValue:persistentId forProperty:MPMediaItemPropertyPersistentID];
[query addFilterPredicate:predicate];
NSArray *mediaItems = [query items];
//this array will consist of song with given persistentId. add it to collection and play it
MPMediaItemCollection *col = [[MPMediaItemCollection alloc] initWithItems:mediaItems];
///....
[col release];
}
关于iPhone sdk,保存MPMediaItemCollection吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1745739/
所以,我已经在 NSUserDefaults 中存储了一些mpmediaitemcollection。我已经在 UICollectionView 上检索到它。 这是我的代码: func collect
我正在尝试将我的旧播放器从 Objective-C 重写为 Swift(凭内存),但遇到了麻烦。我有很多这样的歌曲 let query = MPMediaQuery.songsQuery() quer
我正在制作一个允许用户使用 MPMusicPlayerController 制作播放列表和编辑播放列表的应用程序。我已经能够制作播放列表然后检索它以便播放。我不知道的是如何将 playlist(MPM
我的目标是获取 iPod 库中播放列表的封面图片。我做了类似的事情 playlistMediaItemCollections = MPMediaQuery.playlistsQuery().coll
希望玩MPMediaItemcollection使用 MPMusicPlayerController . musicPlayer = [MPMusicPlayerController applicat
为什么以下结果会产生一个充满“艺术家”的表格 View ,而不是一个充满实际艺术家姓名的表格 View ?我哪里做错了?如何从收藏中提取艺术家值(value)?感谢所有帮助... var tableD
我的应用程序中有一个播放列表屏幕,用户可以在其中选择播放列表中的任何歌曲,应用程序将从该歌曲开始播放。 我使用以下代码: - (void)tableView:(UITableView *)tableV
我在 MPMediaItemsCollection 中设置 N 个项目,其中一些项目不是唯一的(该集合代表一个播放列表,其中同一首歌曲可能出现两次)。 - (void)setLastSongWithI
我正在开发一个与 iOS 上的 iPod Music 应用程序集成的应用程序。它显示不同的音乐分组(即 MPMediaItemCollections),并允许用户使用 [MPMusicPlayerCo
如何使用 NSUserDefaults 持久化 MPMediaItemCollection 对象? MPMediaItemCollection 对象是从 iPod 中选择的一首歌曲。 我已经为此苦苦挣
我正在制作一个应用程序,用户可以在其中的设置选项卡中选择一首歌曲,并根据需要在不同的 View 中播放。我想要它,以便在用户关闭应用程序并再次打开它时可以存储该项目。 我已经设法允许用户选择歌曲并将其
我尝试用 Swift 制作我自己的音乐播放器。我需要跳转到我的 MPMediaItemCollection 的特定歌曲/索引并开始播放它,但我只能找到像 skipToNextItem() 和 skip
我使用这段代码来选择轨道 //open the media picker, allow the inport of any type of audio MPMediaPickerController
我想在我的应用程序中使用 avplayer 播放设备歌曲。在 NSLog 中,我得到数组值 ===> “18023427656013653237”, "15946441828903552798", "
事情是这样的,我有一个 MPMediaItemCollection,其中包含用户选择的项目(来自库)。我使用 mediaPicker 来做到这一点。现在,我需要从这些项目中获取 URL,以便我可以在
在 iPhone SDK 中使用应用内音频时,可以允许用户从其 iPod 库中选择列表并创建应用内本地播放列表。如果我想坚持这个选择,很容易序列化数据并写入文件,然后恢复。 然而,只是像这样的 Van
我正在使用 xcode 中的苹果 addMusic 示例应用程序,因为我希望能够添加类似的功能(在应用程序的后台播放用户选择的音乐队列)。 它会做一件恼人的事情,当用户在内置 MediaPicker
我是一名优秀的程序员,十分优秀!