iosobjective-cuiwebviewcontrol-center

remove info and control in Control Center from UIWebView


if we place the url which contains video in a UIWebView, and play with it. the control center will have the info and controls of the video.

is there a way to remove this info and control ?

I found this question asking is that UIWebView player a MPMoviePlayerController instance, and how to get a reference to that instance?

although the answer been accepted, but it doesn't reveal the real player in UIWebView, if I knew what it is, maybe I could find more info about how it works, and how to deal with it.

since I'm the one put the UIWebView in the app, I should have the control, right?

I try to get the AVPlayer with url by this question Get current track playing on control center iOS, but it's returning a new AVPlayer, so is AVQueuePlayer and AVPlayerLayer.. no matter what I did to them, there won't be any effect in the control center..

I found this piece in WWDC sessions

Mastering Modern Media Playback

it looks convincing, will this be the right direction ?


Solution

  • I was introduced to method swizzling by @DaidoujiChen

    it helps me filter the event of registering remove control from UIWebView

    find out which method you don't wanna be touched by others

    perform the method by the flag you defined, that's all !

    - (void)avoidWebViewUse_beginReceivingRemoteControlEvents {
    
    if ([ JukeboxMacro sharedSingleton ].requestingRemoteControl) {
    
        [ self avoidWebViewUse_beginReceivingRemoteControlEvents ];
    
    } else {
    
        NSLog(@"UIWebView trying to beginReceivingRemoteControlEvents ");
    
    }}