Really appreciate your help here - what I am noticing is that there is no audio on the video clips I have imported into Xojo. There is definitely sound in the on disk video clip.
So the simulator PIP works (even with no audio audible) but the built version does not allow, or show the button to allow, PIP.
Import into project via the File-Import process (which I guess is the same as dragging into the IDE). I then assign the video in the inspector for the MobileMoviePlayer.
Thanks Greg - that solved the audio missing issue. Something is happening when you import a video file into a project (not sure if just iOS) - these were mp4 files.
Declare Function NSClassFromString Lib "Foundation" (clsName As CFStringRef) As ptr
declare function sharedInstance_ lib "AVFoundation" selector "sharedInstance" (clsRef as ptr) as ptr
Dim AVAudioSessionPtr As ptr = sharedInstance_(NSClassFromString("AVAudioSession"))
declare function setCategory_ lib "AVFoundation" selector "setCategory:mode:options:error:" (obj_id as ptr, category as CFStringRef, mode as CFStringRef, options as UInteger, byref outError as ptr) as Boolean
dim err as ptr
Dim category As String = "AVAudioSessionCategoryPlayback"
Dim mode As String = "AVAudioSessionModeMoviePlayback"
Dim options As UInteger = 2
dim result as Boolean = setCategory_(AVAudioSessionPtr, category, mode, options, err)
if err <> nil then
declare function localizedDescription lib "Foundation" selector "localizedDescription" (obj_id as ptr) as CFStringRef
Dim errorReason As String = localizedDescription(err)
Break //Check value of ErrorReason
elseif result = False then
Break //something else went wrong
end if
No it is completely independent from the background audio entitlement.
This entitlement is to allow your app to play audio/video in the background when your app isn’t facing the user.
The code above tells the system that your app’s purpose is to play video files. Therefore it should stop other audio / video apps playing when you start your app. I believe this is one of the requirements for PiP to work correctly on a real device.
Code is not the same as an Entitlement. Entitlements are basically a plist file that is embedded in your application at build time as part of the signing process.
Yes but you said this was part of the background-audio capability - my terminology may be mixed up. If this doesn’t function using the Background-Audio capability like you indicated it should then is this a bug?
The checkbox I indicated is a capability/entitlement. The code that Jeremie gave you is not. His code is just for telling the OS how the audio in your app needs to be routed, and it can be changed at runtime. Entitlements cannot.
Ah, no. I only indicated it because i happened to have been in there recently and noticed that our dialog didn’t specifically call out video for the one that is named Audio when it should have.
Ok, so recently we realized that over time the section of the IDE which was designated for Entitlements also had just standard plist entries in it so we renamed it to be called Capabilities. The Background Mode capability is a standard plist entry (not an Entitlement) which tells the OS that your app needs to run in the background for very specific purposes. I suspect this has to do with power usage in that apps that don’t actually need to run code in the background, simply don’t.