0

I have used AVPictureInPictureController in AVPPlayer and initialized it as AVPlayerLayer.

- (id)initWithFrame:(CGRect)frame contentURL:(NSURL*)contentURL
{
    self = [super initWithFrame:frame];
    if (self) {

        AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:contentURL];
        self.moviePlayer = [AVPlayer playerWithPlayerItem:playerItem];
        playerLayer = [AVPlayerLayer playerLayerWithPlayer:self.moviePlayer];

        if ([AVPictureInPictureController isPictureInPictureSupported])
        {
            self.avVPictureInPictureController = [[AVPictureInPictureController alloc] initWithPlayerLayer:playerLayer];
        }


        [playerLayer setFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];


        [self.moviePlayer seekToTime:kCMTimeZero];
        [self.layer addSublayer:playerLayer];


        self.contentURL = contentURL;

        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerFinishedPlaying) name:AVPlayerItemDidPlayToEndTimeNotification object:playerItem];

        [self initializePlayer:frame];
    }
    return self;
}

Now when I try to present FPPopoverController ( a custom class to present PopOvers on iPhone and iPad ) it doesn't show on the screen.

I use the following code to present FPPopOverController

//That's how I call

 self.audioSubtitlePopoverController.presentPopoverFromPoint(point)


//Definition of presentPopoverFromPoint  

-(void)presentPopoverFromPoint:(CGPoint)fromPoint
{
    self.origin = fromPoint;

    //NO BORDER
    if(self.border == NO)
    {
        _viewController.title = nil;
        _viewController.view.clipsToBounds = YES;
    }

    _contentView.relativeOrigin = [_parentView convertPoint:fromPoint toView:_contentView];

    [self.view removeFromSuperview];
    NSArray *windows = [UIApplication sharedApplication].windows;
    if(windows.count > 0)
    {
          _parentView=nil;
        _window = [windows objectAtIndex:0];
        //keep the first subview
        if(_window.subviews.count > 0)
        {
            _parentView = [_window.subviews lastObject];

            NSLog(@"%@ %@",_parentView,_viewController);
            [_parentView addSubview:self.view];
            [_viewController viewDidAppear:YES];
            [self.view bringSubviewToFront:_parentView];

        }

   }
    else
    {
        [self dismissPopoverAnimated:NO];
    }



    [self setupView];
    self.view.alpha = 0.0;
    [UIView animateWithDuration:0.2 animations:^{

        self.view.alpha = self.alpha;
    }];

    [[NSNotificationCenter defaultCenter] postNotificationName:@"FPNewPopoverPresented" object:self];

    //navigation controller bar fix
    if([_viewController isKindOfClass:[UINavigationController class]])
    {
        UINavigationController *nc = (UINavigationController*)_viewController;
        UINavigationBar *b = nc.navigationBar;
        CGRect bar_frame = b.frame;
        bar_frame.origin.y = 0;
        b.frame = bar_frame;
    }
}

Even present from view doesn't work too

self.audioSubtitlePopoverController.presentPopoverFromView(self.view)
// Definition of presentPopoverFromView
-(void)presentPopoverFromView:(UIView*)fromView
{
    SAFE_ARC_RELEASE(_fromView);
    _fromView = SAFE_ARC_RETAIN(fromView);
    [self presentPopoverFromPoint:[self originFromView:_fromView]];
}

Can anyone please assist. Would be grateful.

Taimur Ajmal
  • 2,778
  • 6
  • 39
  • 57

1 Answers1

1

FPPopover is deprecated.

You should use the native Possibility to display Popovers or WEPopover instead.

Community
  • 1
  • 1
Maurice
  • 1,466
  • 1
  • 13
  • 33
  • I want to use PopOver that is compatible for both iPhone and iPad. WePopover is not available for iPhone. " WEPopover is an attempt to create a generalized version of the UIPopoverController which is unfortunately only available for the iPad" – Taimur Ajmal Aug 21 '16 at 13:46