How to remove app name from Control Center - Music?
Asked Answered
L

3

12

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".

Lula answered 4/4, 2016 at 6:29 Comment(5)
is there any specific requirement to user 'systemMusicPlayer' ?Fractocumulus
Duplicate? https://mcmap.net/q/1010098/-how-to-hide-quot-now-playing-url-quot-in-control-center/2415822Preussen
@JAL, thanks for the links, but its not working. I have tried this.Lula
you can use AVPlayer/AvAudio player to play the music, which will be not shown in the control centerFractocumulus
@Pyro, its playing from an HTML 5 file and not from my app.Lula
W
4

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.

Watcher answered 23/4, 2016 at 19:5 Comment(0)
C
6

Have you tried

[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
Congratulation answered 20/4, 2016 at 11:38 Comment(0)
W
4

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.

Watcher answered 23/4, 2016 at 19:5 Comment(0)
B
3

1 Try setting up the defaultCenter's nowPlayingInfo dictionary to display a media item with no title right after loading the content in your UIWebView.

MPNowPlayingInfoCenter *infoCenter = [MPNowPlayingInfoCenter defaultCenter];

NSDictionary *nowPlayingInfo = @{
                                 MPMediaItemPropertyTitle : @"",
                                 MPMediaItemPropertyArtist : @""
                                 };

[infoCenter setNowPlayingInfo:[NSDictionary dictionaryWithDictionary:nowPlayingInfo]];

2 When using background audio, specify that your app should not receive remote control events.

[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
Burgher answered 20/4, 2016 at 11:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.