Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove app name from Control Center - Music?

I am working on an app (which isn't a music app) however, at some point, it can play audio inside a UIWebView (from an html 5 file) which enabled auto play.

The problem is that, my app name is showing up in iPhone's Control Center inside "Music" section. When I taps on my app name, it will open up my app. However, I don't want this behavior.

I have tried setting [MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = nil; inside AppDelegates, when app goes to background or comes to foreground or even terminate case. But its still showing up the app name? Any clue? Is there something I'm missing to set?

Oh and yes, this may help someone to know exact issue, in a view controller where I'm playing an audio inside UIWebView, I have written following code to handle currently playing song in my iPhone music (or any other) app.

- (void) viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    MPMusicPlayerController *mp = [MPMusicPlayerController systemMusicPlayer];
    if(mp.playbackState == MPMoviePlaybackStatePlaying) {
        isSystemMediaPlayerPlaying = YES;
    }
}

- (void) viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];

    if(isSystemMediaPlayerPlaying) {
        MPMusicPlayerController *mp = [MPMusicPlayerController systemMusicPlayer];
        [mp play];
        isSystemMediaPlayerPlaying = NO;
    }
}

For a note, isSystemMediaPlayerPlaying is a BOOL type.

Screenshot:

enter image description here

P.S. Instead of "You Tube", you can consider "My App Name".

like image 701
Hemang Avatar asked Apr 04 '16 06:04

Hemang


People also ask

How do I remove the music app from the Control Center on my iPhone?

Go to Settings > Control Center. Tap the Remove button , then tap Remove next to the app or feature that you want to remove.

How do I remove music from my iPhone lock screen IOS 15?

At your home screen, click the gear icon (settings) to visit device settings. Then what you have to do is open the notifications tab. You have to find and click on Music and slide the notification toggle to disable it. Restart your iPhone after doing so and the music app lock screen problem should be fixed easily.


1 Answers

Don't call systemMusicPlayer in your app. if music is playing when enter your app, after exit your app, it will resume by itself, just discard your code above.

like image 188
Allen Avatar answered Sep 20 '22 19:09

Allen