Is it possible to write an iPhone app to control the built in iPod?

Hey,

       I'm trying to learn how to program on the iPhone, so I was wondering if it was possible to control the built in iPod from a third party app.

If it is possible, could you please point me to a good tutorial that can help me make this?

Thanks in advance!
errangAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hamidreza VakilianSenior iOS/Android DeveloperCommented:
The MediaPlayer framework is what you are looking for. There is a useful guide which also contains a link to the MediaPlayer API overview.

Specifically, you're looking for MPMusicPlayerController. Your app can control either a dedicated app media player or the iPod media player which appears to be what you want.

A simple example would be something like (header omitted):
@implementation MyPlaybackController

- (id)initWithNibName:(NSString *)nibName bundle:(id)bundleOrNil 
{
  if ((self = [super initWithNibName:nibName bundle:bundleOrNil])) {
    self.musicPlayer = [MPMusicPlayerController iPodMusicPlayer];
  }  
  return self;
}

- (IBAction)skipForward:(id)sender
{
  [self.musicPlayer skipToNextItem];
}

- (IBAction)skipBack:(id)sender
{
  [self.musicPlayer skipToPreviousItem];
}

- (IBAction)togglePlayback:(id)sender
{
  if (self.musicPlayer.playbackState == MPMusicPlaybackStatePlaying) {
    [self.musicPlayer pause];
  } else {
    [self.musicPlayer play];
  }
}

@end

Open in new window

Do take time to read the documentations and take note of the caveats mentioned with regards to Home Sharing. You'll also want to register for notifications in changes to the player state that can occur from outside your control.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
errangAuthor Commented:
Ah, sweet, thanks!

I checked out this page: http://developer.apple.com/library/ios/#documentation/Miscellaneous/Conceptual/iPhoneOSTechOverview/iPhoneOSFrameworks/iPhoneOSFrameworks.html

It isn't possible for me to intercept incoming calls, or access the complete functionality of the mail app, is there?
0
Hamidreza VakilianSenior iOS/Android DeveloperCommented:
To intercept calls and mail you should access private APIs.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

errangAuthor Commented:
Hm.. by private APIs, do you mean you need to be in the developer program to use them? Or do we need to develop those ourselves?

If its the first, could you please point me to them? =)
0
Hamidreza VakilianSenior iOS/Android DeveloperCommented:
These private APIs are available for all. You can check out http://iphonedevwiki.net for private frameworks. These private frameworks are often used for jailbroken devices development (the private framework's header you find in this site are reverse engineered by hackers). AppStore forbids developers from using these private APIs. If you use such APIs in your app, it will be rejected by AppStore.

-- There's also some apps in appstore which are exceptions to this rule (cisco's anyconnect, tapdictionary, etc...). Probably these applications have signed some extra agreements with apple regarding using these private frameworks. Ask Apple developer support for accurate information on this...
If you called them, inform us from what they told you.
You will be appreciated alot...
0
errangAuthor Commented:
>>Ask Apple developer support for accurate information on this...

Alright, will do =), thanks for the information =D
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
iOS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.