Just experimenting with the new MobileMoviePlayer control and getting it working etc is extremely simple and works well. What it doesn’t do is carry on playing in the Picture in Picture mode like other video applications. Is this possible using Xojo - do I need declares to make this work or is there a specific entitlement I need to enable?
What is odd Is when I run the project in Xojo and view it on the simulator the PIP option is shown and works fine. When I build and copy to the device (iPad Pro 12.9) the PIP option is not shown?
Confused!
In the simulator I see this:
In the built app I only see the expand arrows to the left of this button.
It’s unclear to me what Apple class that Xojo is using, but if it’s an AVPlayerViewController you should be able to do this (untested):
Declare sub setAllowsPiP Lin “AVFoundation.framework” selector “setAllowsPictureInPicturePlayback:” (Obj as ptr, yesNo as Boolean)
SetAllowsPiP(myVideoPlayer.handle, true)
The other thing you will need to do is set the entitlement. Currently you can get to this by going to the iOS build target and on the inspector, click to the Advanced tab. In the list that’s there, turn on Background Modes and then click Options. You’ll need to select Audio (actually it’s Audio, Airplay and Picture in Picture).
Declare sub setAllowsPiP Lib "AVFoundation.framework" selector "setAllowsPictureInPicturePlayback:" (Obj as ptr, yesNo as Boolean)
SetAllowsPiP(myVideoPlayer.handle, true)
I can’t seem to find what is the underlying class of MobileMoviePlayer…
Using simple declares to get the class name and also using Reveal give AVPlayerView which is not a standard AVFoundation class on iOS.
All attempts of declaring into MobileMoviePlayer resulted in a crash.
FWIW you can also use a declare to find out what the underlying class of a handle is on macOS and iOS:
Declare Function getClassName Lib "Foundation" selector "className" (obj As ptr) As CFstringref
Var className as String = getClassName(item.Handle)
Break
My guess is that the simulator uses AVPlayerView and the device uses AVPlayerViewController as they’re darn near identical and you are expected to just not call the macOS-only selectors.
That said, while I’m not getting errors, I am getting crashes for unknown selectors.
I’m trying to do this:
Declare Function player Lib "AVKit" selector "player" (obj As ptr) As ptr
Who should file this sorry - I don’t understand enough about the issue to be able to log a comprehensive bug report but can log a basic call referencing this discussion?
I was able to get access to the AVPlayerViewController like this:
Declare Function NSClassFromString Lib "Foundation" (clsName As CFStringRef) As ptr
Declare Function isKindOfClass Lib "UIKit" selector "isKindOfClass:" (obj_id As ptr, cls As ptr) As Boolean
Declare function nextResponder lib "UIKit" selector "nextResponder" (obj as ptr) as ptr
Var AVPlayerViewController as ptr = nextResponder(MoviePlayer1.Handle)
if isKindOfClass(AVPlayerViewController, NSClassFromString("AVPlayerViewController")) then
Declare sub setAllowsPiP Lib "AVKit" selector "setAllowsPictureInPicturePlayback:" (Obj as ptr, yesNo as Boolean)
setAllowsPiP(AVPlayerViewController, true)
end if