Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can i enable picture in picture in player #497

Closed
Najamus opened this issue Feb 8, 2022 · 7 comments
Closed

How can i enable picture in picture in player #497

Najamus opened this issue Feb 8, 2022 · 7 comments
Labels

Comments

@Najamus
Copy link

Najamus commented Feb 8, 2022

Basically i wanted to add Picture in Picture functionality in player i tried but didn't found a solution how to enable it while using this library.

Thanks & Regards

@Najamus Najamus added the feature label Feb 8, 2022
@changsanjiang
Copy link
Owner

@Najamus

// start pip
[_player.playbackController startPictureInPicture];

// stop
// [_player.playbackController stopPictureInPicture];

// pip methods
// - (BOOL)isPictureInPictureSupported API_AVAILABLE(ios(14.0));
// @property (nonatomic) BOOL requiresLinearPlaybackInPictureInPicture API_AVAILABLE(ios(14.0));
// @property (nonatomic, readonly) SJPictureInPictureStatus pictureInPictureStatus API_AVAILABLE(ios(14.0));
// @property (nonatomic, copy, nullable) void(^restoreUserInterfaceForPictureInPictureStop)(id<SJVideoPlayerPlaybackController> controller, void(^completionHandler)(BOOL restored));
// - (void)startPictureInPicture API_AVAILABLE(ios(14.0));
// - (void)stopPictureInPicture API_AVAILABLE(ios(14.0));

@Najamus
Copy link
Author

Najamus commented Feb 9, 2022

@changsanjiang thanks brother but i need to confirm one thing how to add picture in picture icon in player currently there is no icon is showing related to pip.

Thanks For Your Reply.

@changsanjiang
Copy link
Owner

@Najamus you can add a custom pip button to player or using SJVideoPlayer. (there are no such buttons on the SJBaseVideoPlayer);

        startImage = [AVPictureInPictureController.pictureInPictureButtonStartImage imageWithTintColor:UIColor.whiteColor];
        stopImage = [AVPictureInPictureController.pictureInPictureButtonStopImage imageWithTintColor:UIColor.whiteColor];

@Najamus
Copy link
Author

Najamus commented Feb 11, 2022

i added custom button in top adapter and on its click i add this code. it always got to picture in picture not supported.

@objc func btnPictureInPictureAction() {
    if #available(iOS 14.0, *) {
        if player.playbackController.isPictureInPictureSupported() {
            print("PictureInPictureAction Start")
            player.playbackController.startPictureInPicture()
        } else {
             // Always come there.... :/
            print("PictureInPictureAction Not Supported")
        }
    } else {
        // Fallback on earlier versions
        print("PictureInPictureAction Not Available")
    }
}

One More thing brother. Could you please share Swift File of SJFloatSmallViewTransitionController.

Thanks

@Najamus
Copy link
Author

Najamus commented Feb 17, 2022

HI Brother Just tell me one thing, im using SJVideoPlayer, when i enabled picture in picture in my project from capabilities now player default show picture in picture icon on top right & its working correctly.

i just need to change that pip icon tint color currently it adopt application accent/tint color but i wnat to change it with white color.

Thanks & Regards
Najam

@changsanjiang
Copy link
Owner

@Najamus

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        
        SJVideoPlayer.updateResources{ res in
//            res.progressThumbSize = 8
//            res.progressTraceColor = UIColor.white
//            res.progressTrackColor = UIColor(white: 0.4, alpha: 1.0)
//            res.progressBufferColor = UIColor(white: 0.3, alpha: 1.0)
            
            if #available(iOS 14.0, *) {
                res.pictureInPictureItemStartImage = AVPictureInPictureController.pictureInPictureButtonStartImage.withTintColor(.red)
                res.pictureInPictureItemStopImage = ...
            }
        }

        // Override point for customization after application launch.
        return true
    }

@Najamus Najamus closed this as completed Feb 18, 2022
@trial
Copy link

trial commented Mar 19, 2022

setting image color seems no effect,
pictureInPictureItemStartImage is still blue and pictureInPictureItemStopImage is still white

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants