<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Retrieving the currently being played music track</title>
	<atom:link href="http://objcolumnist.com/2010/07/11/retrieving-the-currently-being-played-music-track/feed/" rel="self" type="application/rss+xml" />
	<link>http://objcolumnist.com/2010/07/11/retrieving-the-currently-being-played-music-track/</link>
	<description>Coding under the Hammer</description>
	<lastBuildDate>Tue, 10 Jan 2012 20:25:15 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: Spencer MacDonald</title>
		<link>http://objcolumnist.com/2010/07/11/retrieving-the-currently-being-played-music-track/comment-page-1/#comment-823</link>
		<dc:creator>Spencer MacDonald</dc:creator>
		<pubDate>Tue, 04 Jan 2011 12:23:00 +0000</pubDate>
		<guid isPermaLink="false">http://objcolumnist.com/?p=213#comment-823</guid>
		<description>Glad I could help :)

If you make an application, let me know what it is.</description>
		<content:encoded><![CDATA[<p>Glad I could help <img src='http://objcolumnist.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If you make an application, let me know what it is.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marty</title>
		<link>http://objcolumnist.com/2010/07/11/retrieving-the-currently-being-played-music-track/comment-page-1/#comment-822</link>
		<dc:creator>Marty</dc:creator>
		<pubDate>Sat, 01 Jan 2011 21:13:58 +0000</pubDate>
		<guid isPermaLink="false">http://objcolumnist.com/?p=213#comment-822</guid>
		<description>Got it! Here is my implementation:

MPMediaPropertyPredicate *predicate = [MPMediaPropertyPredicate predicateWithValue:[SongItem objectAtIndex:1] forProperty:MPMediaItemPropertyPersistentID];
MPMediaQuery *mySongQuery = [[MPMediaQuery alloc] init];
[mySongQuery addFilterPredicate: predicate];
[musicPlayer setQueueWithQuery:mySongQuery];
[musicPlayer play];

Works like a charm! Thanks for your input!!!!</description>
		<content:encoded><![CDATA[<p>Got it! Here is my implementation:</p>
<p>MPMediaPropertyPredicate *predicate = [MPMediaPropertyPredicate predicateWithValue:[SongItem objectAtIndex:1] forProperty:MPMediaItemPropertyPersistentID];<br />
MPMediaQuery *mySongQuery = [[MPMediaQuery alloc] init];<br />
[mySongQuery addFilterPredicate: predicate];<br />
[musicPlayer setQueueWithQuery:mySongQuery];<br />
[musicPlayer play];</p>
<p>Works like a charm! Thanks for your input!!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Spencer MacDonald</title>
		<link>http://objcolumnist.com/2010/07/11/retrieving-the-currently-being-played-music-track/comment-page-1/#comment-821</link>
		<dc:creator>Spencer MacDonald</dc:creator>
		<pubDate>Sat, 01 Jan 2011 20:17:17 +0000</pubDate>
		<guid isPermaLink="false">http://objcolumnist.com/?p=213#comment-821</guid>
		<description>Take this bit of code:

for (MPMediaItem *song in itemsFromGenericQuery) {
	songTitle = [song valueForProperty: MPMediaItemPropertyTitle];
	[SongName addObject:songTitle];
	songID = [song valueForProperty: MPMediaItemPropertyPersistentID];
	[SongItem addObject:songID];
}


You are looping through an array of MPMediaItems (what you need to pass to the player), and you are then storing an array of song titles and an array of song IDs.

So you have two options:

1) Keep an array of the MPMediaItems
2) Use the MPMediaItemPropertyPersistentID of the MPMediaItems, to retrieve it at a later point. MPMediaPropertyPredicate should do that for you.</description>
		<content:encoded><![CDATA[<p>Take this bit of code:</p>
<p>for (MPMediaItem *song in itemsFromGenericQuery) {<br />
	songTitle = [song valueForProperty: MPMediaItemPropertyTitle];<br />
	[SongName addObject:songTitle];<br />
	songID = [song valueForProperty: MPMediaItemPropertyPersistentID];<br />
	[SongItem addObject:songID];<br />
}</p>
<p>You are looping through an array of MPMediaItems (what you need to pass to the player), and you are then storing an array of song titles and an array of song IDs.</p>
<p>So you have two options:</p>
<p>1) Keep an array of the MPMediaItems<br />
2) Use the MPMediaItemPropertyPersistentID of the MPMediaItems, to retrieve it at a later point. MPMediaPropertyPredicate should do that for you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marty</title>
		<link>http://objcolumnist.com/2010/07/11/retrieving-the-currently-being-played-music-track/comment-page-1/#comment-820</link>
		<dc:creator>Marty</dc:creator>
		<pubDate>Sat, 01 Jan 2011 18:01:45 +0000</pubDate>
		<guid isPermaLink="false">http://objcolumnist.com/?p=213#comment-820</guid>
		<description>Thanks for the response! I&#039;m pretty much a newb programmer. Are you saying I need to use a something other than collectionWithItems to use the array of MPMediaItemPropertyPersistentIDs ? If so, what would I use?

Any code example you you could provide would be deeply helpful.

Thanks ahead of time!</description>
		<content:encoded><![CDATA[<p>Thanks for the response! I&#8217;m pretty much a newb programmer. Are you saying I need to use a something other than collectionWithItems to use the array of MPMediaItemPropertyPersistentIDs ? If so, what would I use?</p>
<p>Any code example you you could provide would be deeply helpful.</p>
<p>Thanks ahead of time!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Spencer MacDonald</title>
		<link>http://objcolumnist.com/2010/07/11/retrieving-the-currently-being-played-music-track/comment-page-1/#comment-819</link>
		<dc:creator>Spencer MacDonald</dc:creator>
		<pubDate>Sat, 01 Jan 2011 12:55:12 +0000</pubDate>
		<guid isPermaLink="false">http://objcolumnist.com/?p=213#comment-819</guid>
		<description>Your problem is:
&lt;code&gt;
MPMediaItemCollection *collection = [MPMediaItemCollection collectionWithItems:[NSArray arrayWithObject:[SongItem objectAtIndex:1]]];
&lt;/code&gt;

&lt;em&gt;collectionWithItems:&lt;/em&gt; expects an array of &lt;strong&gt;MPMediaItem&lt;/strong&gt;s, not an array of &lt;strong&gt;MPMediaItemPropertyPersistentID&lt;/strong&gt;s.</description>
		<content:encoded><![CDATA[<p>Your problem is:<br />
<code><br />
MPMediaItemCollection *collection = [MPMediaItemCollection collectionWithItems:[NSArray arrayWithObject:[SongItem objectAtIndex:1]]];<br />
</code></p>
<p><em>collectionWithItems:</em> expects an array of <strong>MPMediaItem</strong>s, not an array of <strong>MPMediaItemPropertyPersistentID</strong>s.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marty</title>
		<link>http://objcolumnist.com/2010/07/11/retrieving-the-currently-being-played-music-track/comment-page-1/#comment-818</link>
		<dc:creator>Marty</dc:creator>
		<pubDate>Sat, 01 Jan 2011 03:38:01 +0000</pubDate>
		<guid isPermaLink="false">http://objcolumnist.com/?p=213#comment-818</guid>
		<description>Is there a way to use MPMediaItemPropertyPersistentID to actually play a song? I tried this and it doesn&#039;t seem to work:

self.musicPlayer = [MPMusicPlayerController applicationMusicPlayer];

MPMediaQuery *everything = [[MPMediaQuery alloc] init];
NSArray *itemsFromGenericQuery = [everything items];
SongName = [[NSMutableArray alloc] init];
SongItem = [[NSMutableArray alloc] init];
NSString *songTitle;
NSString *songID;
//Collect names &amp; ID for entire music library &amp; put into arrays
for (MPMediaItem *song in itemsFromGenericQuery) {
songTitle = [song valueForProperty: MPMediaItemPropertyTitle];
[SongName addObject:songTitle];
songID = [song valueForProperty: MPMediaItemPropertyPersistentID];
[SongItem addObject:songID];
}

NSLog (@&quot;%@&quot;, [SongName objectAtIndex:1]);
NSLog (@&quot;%@&quot;, [SongItem objectAtIndex:1]);
// Play the second song in the list
MPMediaItemCollection *collection = [MPMediaItemCollection collectionWithItems:[NSArray arrayWithObject:[SongItem objectAtIndex:1]]];
[self.musicPlayer setQueueWithItemCollection:collection];
[self.musicPlayer play];</description>
		<content:encoded><![CDATA[<p>Is there a way to use MPMediaItemPropertyPersistentID to actually play a song? I tried this and it doesn&#8217;t seem to work:</p>
<p>self.musicPlayer = [MPMusicPlayerController applicationMusicPlayer];</p>
<p>MPMediaQuery *everything = [[MPMediaQuery alloc] init];<br />
NSArray *itemsFromGenericQuery = [everything items];<br />
SongName = [[NSMutableArray alloc] init];<br />
SongItem = [[NSMutableArray alloc] init];<br />
NSString *songTitle;<br />
NSString *songID;<br />
//Collect names &amp; ID for entire music library &amp; put into arrays<br />
for (MPMediaItem *song in itemsFromGenericQuery) {<br />
songTitle = [song valueForProperty: MPMediaItemPropertyTitle];<br />
[SongName addObject:songTitle];<br />
songID = [song valueForProperty: MPMediaItemPropertyPersistentID];<br />
[SongItem addObject:songID];<br />
}</p>
<p>NSLog (@&#8221;%@&#8221;, [SongName objectAtIndex:1]);<br />
NSLog (@&#8221;%@&#8221;, [SongItem objectAtIndex:1]);<br />
// Play the second song in the list<br />
MPMediaItemCollection *collection = [MPMediaItemCollection collectionWithItems:[NSArray arrayWithObject:[SongItem objectAtIndex:1]]];<br />
[self.musicPlayer setQueueWithItemCollection:collection];<br />
[self.musicPlayer play];</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Spencer MacDonald</title>
		<link>http://objcolumnist.com/2010/07/11/retrieving-the-currently-being-played-music-track/comment-page-1/#comment-791</link>
		<dc:creator>Spencer MacDonald</dc:creator>
		<pubDate>Mon, 29 Nov 2010 20:10:46 +0000</pubDate>
		<guid isPermaLink="false">http://objcolumnist.com/?p=213#comment-791</guid>
		<description>No unfortunately it wouldn&#039;t, as they would (more than likely) be using their own audio player within their applications.

If another application used the iPod to play music, that would work.</description>
		<content:encoded><![CDATA[<p>No unfortunately it wouldn&#8217;t, as they would (more than likely) be using their own audio player within their applications.</p>
<p>If another application used the iPod to play music, that would work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Austin</title>
		<link>http://objcolumnist.com/2010/07/11/retrieving-the-currently-being-played-music-track/comment-page-1/#comment-790</link>
		<dc:creator>Austin</dc:creator>
		<pubDate>Mon, 29 Nov 2010 20:05:44 +0000</pubDate>
		<guid isPermaLink="false">http://objcolumnist.com/?p=213#comment-790</guid>
		<description>Does retrieving nowPlayingItem work with non-iPod media players that are playing music in the background? (ie Pandora)</description>
		<content:encoded><![CDATA[<p>Does retrieving nowPlayingItem work with non-iPod media players that are playing music in the background? (ie Pandora)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

