Help with comparing iTunes notif. player state

Discussion in 'Mac Programming' started by Avicenna, Feb 25, 2011.

  1. Avicenna macrumors member

    Joined:
    Jul 16, 2009
    #1
    Here is a typical iTunes playerInfo notification:

    Code:
    2011-02-25 08:42:26.583 Demo[472:a0f] {
        Album = "Doo-Wops & Hooligans (Deluxe Version)";
        "Album Artist" = "Bruno Mars";
        "Album Rating" = 0;
        "Album Rating Computed" = 1;
        Artist = "Bruno Mars";
        "Artwork Count" = 1;
        "Disc Count" = 1;
        "Disc Number" = 1;
        Genre = Pop;
        "Library PersistentID" = 1734896675364731040;
        Location = ****
        Name = "Just the Way You Are (feat. Lupe Fiasco) [Remix] {Bonus Track}";
        PersistentID = 7070657166844949486;
        "Play Count" = 0;
        "Play Date" = "1904-01-01 00:00:00 -0500";
        "Player State" = Playing;
        "Playlist PersistentID" = "-7222080182103823525";
        "Rating Computed" = 1;
        "Skip Count" = 0;
        "Skip Date" = "1904-01-01 00:00:00 -0500";
        "Store URL" = "itms://itunes.com/link?n=Just%20the%20Way%20You%20Are%20(feat.%20Lupe%20Fiasco)%20%5BRemix%5D%20%7BBonus%20Track%7D&an=Bruno%20Mars&pn=Doo-Wops%20%26%20Hooligans%20(Deluxe%20Version)";
        "Total Time" = 238524;
        "Track Count" = 12;
        "Track Number" = 11;
        Year = 2010;
    }
    
    I want to compare the "Player State" 's object. But the object represented by the key "Player State" is not a string so how can I compare with say a state that represents Player Stopped ?

    Something like this"

    if ([information objectForKey:mad:"Player State"] isEqualToString @"Stopped"]) {
    NSLog(@"Stopped!");
    }


    but [information objectForKey:mad:"Player State"] is not a string so I know it won't work.

    Thanks.
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    How did you generate the posted output?

    I was probably code that's something like this:
    Code:
    NSLog( @"%@", information );
    
    Next, think about what code you'd write if you wanted to NSLog
    [information objectForKey:mad:"Player State"].

    Now think about what code you'd write if you wanted an NSString whose contents is the same as what's logged (hint: NSString stringWithFormat:).
     

Share This Page