【问题标题】:Is it possible to access iPhone/iPod Touch music stats through the SDK?是否可以通过 SDK 访问 iPhone/iPod Touch 音乐统计数据?
【发布时间】:2011-01-06 04:31:45
【问题描述】:

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

【问题讨论】:

    标签: iphone statistics ipod-touch


    【解决方案1】:

    Querying the media library...

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

    System Constants...

    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;
    

    【讨论】:

      猜你喜欢
      • 2012-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多