Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

xArtx

macrumors 6502a
Original poster
Mar 30, 2012
764
1
Hi Guys,
I got this simple media player working:

Code:
        // instantiate a music player
        MPMusicPlayerController *myPlayer =
        [MPMusicPlayerController applicationMusicPlayer];
        
        // assign a playback queue containing all media items on the device
        [myPlayer setQueueWithQuery: [MPMediaQuery songsQuery]];
        
        // start playing from the beginning of the queue
        [myPlayer play];

It starts playing your iTunes library.

Is there a simple way to make it start playing a particular track by it's title,
if it happens to known that it will be present on the device?
Cheers, Art.
 
I'm not sure what that means.
I know you can use it to address groups of songs,
but don't know how it achieves my objective.
I already know the song title is in the ipod library.

----------

I'm trying to whip up something of a quick karaoke machine
where the music and lyrics are in foreign languages to help
me learn German particularly.

I know I could just include an mp3 copy in the main bundle,
but that wouldn't be very sleek.
 
Did you read the documentation? Reading and understanding documentation is a core programming skill. The MPMediaQuery documentation has a couple of methods that instantly look useful:

songsQuery and then addFilterPredicate:

If you are expecting someone to write your code for you then sorry, I think that's pointless as you learn nothing.
 
Last edited by a moderator:
Well I'm getting there :)

So I decided to write an app that shows album art and track titles,
and provide basic control of a playlist so I could use it in the car
when that "Accessory Connected" screen normally appears.

My app works until I plug it into the car stereo,
then it appears control over the iPod library,
and access to album art is no longer possible.


Is there a way around this?
 
Did this:
http://www.youtube.com/watch?v=ZE7fo83s1V8

But still can't play a track by title :D

I'm not sure if the video makes it clear, but if you don't get it,
try pressing either of the skip buttons in the music player
ten times as fast as you can... it will only skip about five tracks.
 
Look at the MPMediaPropertyPredicate Class Reference which is used in the MPMediaQuery

http://developer.apple.com/library/...Reference.html#//apple_ref/doc/uid/TP40008219

----------

Look at the MPMediaPropertyPredicate Class Reference which is used in the MPMediaQuery

http://developer.apple.com/library/...Reference.html#//apple_ref/doc/uid/TP40008219

I have never done anything with the media player but it seems like you will have to set up a MPMediaQuery with a predicate upon the song using the addFilterPredicate: method.

the filterPredicate that you added would be where you set up the track name filter
 
Thanks, I am getting somewhere with this now :)
If you use the sample in the docs to retrieve a list of playlists
or titles, you should be able to use that data for the filter.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.