• 获取iPod library中的媒体文件


    获取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);
    }

     

     

     

  • 相关阅读:
    [置顶] 深入理解android之IPC机制与Binder框架
    cdn加速对门户网站产生的影响
    极客技术专题【007期】:jQuery初学者入门
    linux 下信号处理命令trap && linux下各种信号的意义
    利用ACE 自己实现的线程池
    漫谈开发前奏之编译器
    jar,war,ear区别及java基础杂七八
    java出现no XXX in java.library.path的解决办法及eclipse配置
    Windows下GNU之gcc体验方法
    防asp木马运行
  • 原文地址:https://www.cnblogs.com/tekkaman/p/3696911.html
Copyright © 2020-2023  润新知