#import <AVKit/AVKit.h>
#import <Foundation/Foundation.h>
@class TVLManager;
@class UIView;

@protocol VeLivePictureInPictureManagerListener <NSObject>
- (void)onStartPictureInPicture;
- (void)onStopPictureInPicture;
- (void)onClickPictureInPicture;
- (void)onError:(NSInteger)code extraData:(NSDictionary *)extraData;
@end

@interface VeLivePictureInPictureManager : NSObject

// Configure whether to support automatic picture-in-picture in background
// Default is NO
@property(nonatomic, assign)
    BOOL canStartPictureInPictureAutomaticallyFromInline API_AVAILABLE(ios(14.2)
    );

// Whether to automatically hide the current player's view controller after
// starting picture-in-picture, default is NO
@property(nonatomic, assign) BOOL autoHideViewController;

// Expose shared instance methods to RN
+ (instancetype)sharedInstance;
+ (instancetype)getInstance;

// Expose other methods that need to be called from RN
- (void)setupPlayer:(TVLManager *)player;
- (void)enablePictureInPicture;
- (void)disablePictureInPicture;
- (void)startPictureInPicture;
- (void)stopPictureInPicture;
- (void)destroyPictureInPicture;
- (BOOL)isPictureInPictureSupported;
- (void)setListener:(id<VeLivePictureInPictureManagerListener>)listener;

// register a PIP controller observer, returns an observer ID
- (NSString *)addPipControllerObserver:
    (void (^)(AVPictureInPictureController *pipController))observer;

// remove a PIP controller observer by its ID
- (void)removePipControllerObserver:(NSString *)observerId;

// This method is used to remove all observers registered for the PIP controller
- (void)removeAllPipControllerObservers;

@end
