是否可以通过 SDK 访问 iPhone/iPod Touch 音乐统计数据?

2023-12-04

我发现可以访问音乐和播放列表,甚至可以播放它们。但是是否可以访问每首音乐附带的统计数据?比如播放次数、明星、日期和收听次数?


查询媒体库...

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

[query addFilterPredicate: [MPMediaPropertyPredicate
                               predicateWithValue: @"Moribund the Squirrel"
                                      forProperty: MPMediaItemPropertyArtist]];
// Sets the grouping type for the media query
[query setGroupingType: MPMediaGroupingAlbum];

NSArray *albums = [query collections];
for (MPMediaItemCollection *album in albums) {
    MPMediaItem *representativeItem = [album representativeItem];
    NSString *artistName =
        [representativeItem valueForProperty: MPMediaItemPropertyArtist];
    NSString *albumName =
        [representativeItem valueForProperty: MPMediaItemPropertyAlbumTitle];
    NSLog (@"%@ by %@", albumName, artistName);

    NSArray *songs = [album items];
    for (MPMediaItem *song in songs) {
        NSString *songTitle =
            [song valueForProperty: MPMediaItemPropertyTitle];
        NSLog (@"\t\t%@", songTitle);
    }
}

系统常数...

NSString *const MPMediaItemPropertyPersistentID;      // filterable
NSString *const MPMediaItemPropertyMediaType;         // filterable
NSString *const MPMediaItemPropertyTitle;             // filterable
NSString *const MPMediaItemPropertyAlbumTitle;        // filterable
NSString *const MPMediaItemPropertyArtist;            // filterable
NSString *const MPMediaItemPropertyAlbumArtist;       // filterable
NSString *const MPMediaItemPropertyGenre;             // filterable
NSString *const MPMediaItemPropertyComposer;          // filterable
NSString *const MPMediaItemPropertyPlaybackDuration;
NSString *const MPMediaItemPropertyAlbumTrackNumber;
NSString *const MPMediaItemPropertyAlbumTrackCount;
NSString *const MPMediaItemPropertyDiscNumber;
NSString *const MPMediaItemPropertyDiscCount;
NSString *const MPMediaItemPropertyArtwork;
NSString *const MPMediaItemPropertyLyrics;
NSString *const MPMediaItemPropertyIsCompilation;     // filterable

NSString *const MPMediaItemPropertyPodcastTitle;     // filterable

NSString *const MPMediaItemPropertyPlayCount;
NSString *const MPMediaItemPropertySkipCount;
NSString *const MPMediaItemPropertyRating;
NSString *const MPMediaItemPropertyLastPlayedDate;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

是否可以通过 SDK 访问 iPhone/iPod Touch 音乐统计数据? 的相关文章

  • IOS - ObjC Google 地图 Api 密钥

    我只是按照上面提到的做对了一切here https developers google com maps documentation ios start adding the google maps sdk for ios to your
  • Objective c 中的 UIButton 虚线下划线

    正常下划线有效 但点下划线似乎不起作用 UIButton btn UIButton buttonWithType UIButtonTypeCustom btn frame CGRectMake 100 10 300 300 NSMutabl
  • 在 Facebook 墙上添加照片

    void postToWall FBStreamDialog dialog FBStreamDialog alloc init autorelease dialog userMessagePrompt NSString stringWith
  • 自定义 UITableViewCell 中按钮上的 IBAction

    使用 iOS 5 我有一个场景 我必须使用自定义单元格创建一个 tableView 自定义单元格有一个名为 TainingCellController 的控制器 UITableViewCell 的子类和一个 NIB 文件 TrainingC
  • Xcode 8 - 删除了一些按钮边框

    我刚刚将 Xcode 版本从 7 3 更新到 8 0 一些按钮边框消失了 代码看起来很好 所以我真的不知道各层发生了什么 顺便说一句 在其他一些控制器中我可以看到图层边框 self button layer borderColor bord
  • 我需要释放手势识别器吗?

    如果我将手势识别器添加到名为的表格单元格中cell e g UILongPressGestureRecognizer longPressRecognizer UILongPressGestureRecognizer alloc initWi
  • iPhone切换按钮的实现

    我想在我的 iPhone 应用程序中创建一个切换按钮 但是 我不知道最好的方法是什么 我正在考虑两种选择 我可以对 UIButton 进行子类化 这样我就不必实现触摸处理 我可以创建一个返回一个布尔值的方法 指示按钮是处于打开还是关闭状态
  • CGContextSetLineWidth(context, 1) - 宽度几乎总是至少 2 像素而不是 1

    With CGContextSetLineWidth context 1 宽度几乎总是至少 2 像素而不是 1 QQCandleStickLayer m id init self super init if self nil self de
  • 将标题和图像添加到导航栏

    我需要将 UIViewController 的名称和图像设置为导航栏 到目前为止 我可以显示图像 但标题当然丢失了 show image UIImage image UIImage imageNamed bar icon png UIIma
  • iPhone 4G 拍照时应用程序崩溃?

    我已从我的设备中拍摄照片并调整图像大小并将其设置到我的图像视图框架 但我的应用程序在拍摄照片后有时会崩溃 使用调整大小 现在我已经用 iPhone 4G 拍了这张照片 仅当许多应用程序在后台运行 多任务 时 应用程序才会崩溃 那么我该如何解
  • 在ios键盘上方显示建议工具栏

    我是iOS开发的新手 我正在尝试在 ios 5 1 中创建一个具有 textView 的拼写建议类型应用程序 这样如果用户点击键盘的某个键 则建议工具栏会出现在键盘顶部 其中包含所有建议 并且如果用户点击这些建议之一它将显示在 textVi
  • 在 iOS 上保存(私人)应用程序设置?

    我知道NSUserDefaults用于保存 恢复user优先 什么是等效类应用 例如 应用程序可能有一个 上次运行 字段 或者它可能有一个用于在应用程序级别使用的设备的唯一标识的字段 我的目的是将应用程序的设置 而不是用户的设置 保留在设置
  • 无法使用 MFMailComposeViewController 从应用程序发送电子邮件

    我在尝试从我的应用程序发送电子邮件时遇到了一些困难 我尝试了 iCodeBlog 中的这段代码 http icodeblog com 2009 11 18 iphone coding tutorial in application emai
  • 应用程序关闭时下载报刊亭应用程序

    我正在实现一个报摊杂志应用程序 它通过 Urban Airship 推送通知接收新期刊 只要应用程序位于前台或后台 这就可以正常工作 但据我所知 当应用程序完全关闭时也应该触发下载 但发送推送 content available 1如果我的
  • 以点值检测 iPhone 6/6+ 屏幕尺寸

    鉴于新发布的 iPhone 6屏幕尺寸 http www apple com iphone compare iPhone 6 1334h 750w 2x in points 667h 375w iPhone 6 1920 1080 3x i
  • Objective-C 内存管理:发布时崩溃

    我是 Objective C 的新手 似乎无法正确理解内存管理代码 我有以下代码 Media myMedia self myMediaManager getNextMedia self navigationItem title self m
  • 如何从装有 iOS 5 的新 iPhone(供个人使用)获取历史位置数据?

    过去 从 iPhone 上名为solidified db 的文件中获取历史位置数据很容易 例如 请参阅http petewarden github com iPhoneTracker http petewarden github com i
  • 在 iPhone 上搜索 PDF

    经过两天尝试使用 Quartz 从 PDF 中读取注释后 我成功做到了并且发布我的代码 https stackoverflow com questions 4080373 get pdf hyperlinks on ios with qua
  • 如何以编程方式创建选项卡栏

    大家好 我有基于导航的应用程序 其中我也需要在视图之一中实现选项卡栏 在一个视图中我需要 5 个选项卡 有人可以建议我以编程方式创建选项卡栏吗 每个选项卡应导航到另一个 xib 建议始终受到赞赏 问候 以下是 Apple 提供的用于以编程方
  • 获取在 iOS UIFont 中追踪字符的路径

    假设我在 iOS 应用程序中使用了自定义字体 Foo 我已将其添加到我的项目 plist 等中 并且我能够渲染UILabels之类的就很好了 现在 如果我想找出可以 追踪 该字体中的字母 P 的点序列 我将如何获得该点序列 例如 假设我想使

随机推荐