获取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.

  

示例代码

  1. MPMediaQuery *everything = [[MPMediaQuery alloc] init];
  2.  
  3. NSLog(@"Logging items from a generic query...");
  4. NSArray *itemsFromGenericQuery = [everything items];
  5. for (MPMediaItem *song in itemsFromGenericQuery) {
  6. NSString *songTitle = [song valueForProperty: MPMediaItemPropertyTitle];
  7. NSLog (@"%@", songTitle);
  8. }

获取iPod library中的媒体文件的更多相关文章

  1. 获取SD卡中的音乐文件

    小编近期在搞一个音乐播放器App.练练手: 首先遇到一个问题.怎么获取本地的音乐文件? /** * 获取SD卡中的音乐文件 * * @param context * @return */ public ...

  2. ios学习:AVAudioPlayer播放音乐文件及读取ipod库中的音乐文件

    首先要导入AVFoundation框架及 #import <AVFoundation/AVFoundation.h>头文件 注意:要在真机上调试 下面是ipad上的调试效果 下面是代码,代 ...

  3. 教你如何获取ipa包中的开发文件

    教你如何获取ipa包中的开发文件 1. 从iTunes获取到ipa包 2. 修改ipa包然后获取里面的开发文件

  4. WPF中播放声音媒体文件

    这段时间我们小组要给部门的Annual Meeting準备一个WPF的抽奖程序,为了增加程序的有趣性,我们在程序中需要播放背景音乐等.由於对之前从未使用过WPF,所以对其中的声音等媒体文件播放不是很清 ...

  5. 从MediaStorehe和sd中删除媒体文件

    参考资料:http://www.sandersdenardi.com/querying-and-removing-media-from-android-mediastore/ 从媒体表中删除: pri ...

  6. Django (七) token&静态文件&媒体文件

    token&静态文件&媒体文件 1. token 1. 会话技术 2. 服务端会话技术 3. 它实际上就是手动实现的session 4. 实现token 4.1 在models.py中 ...

  7. 与众不同 windows phone (37) - 8.0 文件系统: StorageFolder, StorageFile, 通过 Uri 引用文件, 获取 SD 卡中的文件

    [源码下载] 与众不同 windows phone (37) - 8.0 文件系统: StorageFolder, StorageFile, 通过 Uri 引用文件, 获取 SD 卡中的文件 作者:w ...

  8. WP8.1开发中关于媒体(图片)文件的生成操作,属性如何设置(内容/嵌入资源等);

    (转载)WindowsPhone问题笔记-- 正确选择build action 解决媒体资源无法读取问题 链接:http://www.cnblogs.com/qinxg/archive/2012/07 ...

  9. 背水一战 Windows 10 (91) - 文件系统: Application Data 中的文件操作, Application Data 中的“设置”操作, 通过 uri 引用 Application Data 中的媒体

    [源码下载] 背水一战 Windows 10 (91) - 文件系统: Application Data 中的文件操作, Application Data 中的“设置”操作, 通过 uri 引用 Ap ...

随机推荐

  1. 【转】 python 删除非空文件夹

    转自:https://blog.csdn.net/xiaodongxiexie/article/details/77155864 一般删除文件时使用os库,然后利用os.remove(path)即可完 ...

  2. 系列文章--oracle简单入门教程

    oracle入门很简单:八.oracle数据表 1.创建oracle数据表创建oracle数据表的语法如下: create table命令用于创建一个oracle数据表:括号内列出了数据表应当包含的列 ...

  3. 如何重启 Windows 10 子系统(WSL) ubuntu

    如何重启 Windows 10 子系统(WSL) ubuntu WSL 子系统是基于 LxssManager 服务运行的. 只需要将 LxssManager 重启即可. 可以做成一个 bat 文件. ...

  4. springboot 有关拦截器遇到的问题

    最近改造搜索服务,原来是用 ngx + lua 写的,虽然性能很高,带来的问题是可维护性不太方便,不是指lua语言方面,是因为团队就2个开发人员,另外一个开发人员的擅长语言是Java,于是准备将搜索服 ...

  5. php日志函数error_log

    php内置打印log日志的函数,这个对php程序调试非常高效 1.配置 编辑php.ini文件 log_errors = On 设置log日志存储路径 error_log = /wwwroot/php ...

  6. linux编程基本

    库的使用头文件:.h 里面的函数及变量的声明 比如#include <stdio.h> ,Linux下默认头文件的搜索路径 系统定义的头文件: /usr/include /usr/loca ...

  7. 汇编_指令_XCHG

    交换指令XCHG是两个寄存器,寄存器和内存变量之间内容的交换指令,两个操作数的数据类型要相同,可以是一个字节,也可以是一个字,也可以是双字 .其指令格式如下: XCHG Reg/Mem, Mem/Re ...

  8. Bootstrap-Plugin:弹出框(Popover)插件

    ylbtech-Bootstrap-Plugin:弹出框(Popover)插件 1.返回顶部 1. Bootstrap 弹出框(Popover)插件 弹出框(Popover)与工具提示(Tooltip ...

  9. Autofac log4net Integration Module

    log4net Integration Module While there is no specific assembly for log4net support, you can easily i ...

  10. js中的event

    event代表事件的状态,例如触发event对象的元素.鼠标的位置及状态.按下的键等等.event对象只在事件发生的过程中才有效.event的某些属性只对特定的事件有意义.比如,fromElement ...