iOS developer
iOS developer

Reputation: 317

How to make system music stop when my app loads (iOS)?

So basically I want to stop the iPod music when my app loads up. What would be the best way to do this?

Upvotes: 0

Views: 823

Answers (2)

Nikola Kirev
Nikola Kirev

Reputation: 3152

You should use this method to get access to the iPod App player:

+ (MPMusicPlayerController *)iPodMusicPlayer;

Than you just stop it using the appropriate method.. like this:

MPMusicPlayerController *player = [MPMusicPlayerController iPodMusicPlayer];
[player stop];

You should also add the MediaPlayer framework

Upvotes: 2

Youssef
Youssef

Reputation: 3592

You need to add MediaPlayer.framework to your target.

In your AppDelegate.m import MediaPlayer/MediaPlayer.h and add this in the

application: didFinishLaunchingWithOptions: method:

[[MPMusicPlayerController iPodMusicPlayer] stop];

Upvotes: 4

Related Questions