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

FR: Directly load Picture-in-Picture (PiP) for "play movie.mp4" #835

Open
globalhuman opened this issue Oct 9, 2024 · 4 comments
Open

Comments

@globalhuman
Copy link

I have created some iOS shortcuts to imitate PiP from the stock photos app/gallery app which executes a-shell mini scripts to play a video using the following command:

play movie.mp4

It would be great if there was an option to enable PiP directly from the command such that it opens the video directly in PiP mode i.e.

play movie.mp4 --pip

Is this possible, or are there other methods which would be possible for me to try?

@holzschu
Copy link
Owner

holzschu commented Oct 9, 2024

Hi,
I don't see that option in the apple AVPlayer: https://developer.apple.com/documentation/avfoundation/avplayer
There's an option to enable PiP, but not one to start the player automatically in PiP, unless I missed something.

@holzschu
Copy link
Owner

holzschu commented Oct 9, 2024

I experimented with a few booleans again, but I couldn't make it run PiP automatically. I think Apple doesn't want PiP to be automatic, it has to require user interaction (clicking on the PiP icon).

There's a neat feature that I haven't advertised, though: if you start playing a video, and you haven't clicked to start PictureInPicture, then a-Shell will continue the sound track (because that's feasible) while removing the video track.

@globalhuman
Copy link
Author

I'm not an iOS developer so can only do some basic research on if it's possible. Thanks for experimenting further yourself.

Would the following methods indicate that it could be possible?

https://developer.apple.com/documentation/avkit/avpictureinpicturecontroller/startpictureinpicture()

https://developer.apple.com/documentation/avkit/avpictureinpicturecontroller/canstartpictureinpictureautomaticallyfrominline

@globalhuman
Copy link
Author

After reading a little further I realise that the canStartPictureInPictureAutomaticallyFromInline() method indicates that PiP can start automatically when putting the app to the background. I experimented with adding a short wait X seconds then Go to home screen and the video continue playing in the background. So at least as a workaround that seems to help out for now.

Happy for you to close this if your own research finds that it's not possible and that the workaround is sufficient for your users

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

No branches or pull requests

2 participants