获取iPod library中的媒体文件

  The Media Player framework provides facilities for playing movie, music, audio podcast, and audio book files. This framework also gives your application access to the iPod library, letting you find and play audio-based media items synced from iTunes on the desktop. iPod library access is read-only.

  As shown in Figure 1-1, your application has two ways to retrieve items. The media picker, shown on the left, is an easy-to-use, pre-packaged view controller that behaves like the built-in iPod application’s music selection interface. For many applications, this is sufficient.

  If the picker doesn’t provide the specialized access control that you want, the media query interface—shown to the lower right of your application in the figure—will. It supports predicate-based specification of items from the device iPod library.

  

媒体库的更新

  An MPMediaLibrary object, or media library, represents the state of the set of synced media items (such as songs) on a device. The complete library of media items itself is called the iPod library.

  通过调用以下方法将会产生MPMediaLibraryDidChangeNotification消息,应用程序通过监听此消息以保持与媒体库的同步。

  

API解读

1、MPMediaEntity

  The MPMediaEntity class serves as the abstract superclass for MPMediaItem and MPMediaItemCollection instances, and in turn for MPMediaPlaylist instances. As the superclass, MPMediaEntity defines methods used by those subclasses.

  

2、MPMediaItem:

  A media item represents a single piece of media (such as one song or one video podcast) in the iPod library. A media item has an overall unique identifier, accessed using the MPMediaItemPropertyPersistentID property key, as well as specific identifiers for its metadata. These identifiers persists across application launches.

    

3、MPMediaItemCollection

  A media item collection is a sorted set of media items (instances of the MPMediaItem class) from the iPod library.

  

4、MPMediaPropertyPredicate

  Use one or more MPMediaPropertyPredicate objects, or media property predicates, to define the filter in a media query to retrieve a subset of media items from the iPod library.

  

5、MPMediaQuery

  A media query specifies a set of media items (instances of MPMediaItem) from the iPod library by way of a filter and a grouping type. Filter and grouping type are both optional; an unqualified query matches the entire library.

  

示例代码

MPMediaQuery *everything = [[MPMediaQuery alloc] init];

NSLog(@"Logging items from a generic query...");
NSArray *itemsFromGenericQuery = [everything items];
for (MPMediaItem *song in itemsFromGenericQuery) {
NSString *songTitle = [song valueForProperty: MPMediaItemPropertyTitle];
NSLog (@"%@", songTitle);
}

最新文章

  1. JavaScriptPolyfillShim 在JavaScript中Shim和Polyfill有什么区别?
  2. Random Javascript code snippets
  3. Android 内核初识(3)init进程
  4. JSP个人总结
  5. 【性能测试工具】- Siege
  6. 邓_php_笔试!!!
  7. js中闭包来实现bind函数的一段代码的分析
  8. PHP 程序员危机(转载)
  9. VIM:Found a swap file by the name
  10. 安装pandas时出现环境错误
  11. Vue(二十三)vuex + axios + 缓存 运用 (以登陆功能为例)
  12. Unescaped left brace in regex is illegal here in regex; marked by <-- HERE in m/\${ <-- HERE ([^ \t=:+{}]+)}/ at xxxx/usr/bin/automake line 3939.
  13. mongodb导入csv结构化数据
  14. nil Nil NULL NSNull 之间的区别
  15. day 100天 VUE 父子传值,单页面.
  16. poj 3345 Bribing FIPA (树形背包dp | 输入坑)
  17. Qt Creator中的3D绘图及动画教程(参照NeHe)
  18. 【leetcode 简单】第四十九题 颠倒二进制位
  19. 问下大家,chorme里用开发者工具看headers,点network标签然后刷新网页并没有headers选项,怎么破?
  20. __str__&__repr__

热门文章

  1. docker基于Dockerfile命令创建支持ssh服务的镜像
  2. vmware esxi 4.1单IP访问不同机器
  3. unity的sprite添加点击事件
  4. 进程基本-进程创建,僵尸进程,exec系列函数
  5. [原][Java]eclipse 修改自动提示
  6. 这个移动通讯中 DB 、DBm 、瓦的基本知识的问题:
  7. json中key大小写转换
  8. IDA python使用笔记
  9. --- no python application found, check your startup logs for errors
  10. Python 测试题目-1