Hi,
I am playing audio files with a MobileMoviePlayer on iOS.
I enabled background audio and everything works fine when I play an MP3 file. Audio continues in background when I leave the app.
When I play an M4b audiobook and move out of the app, Picture in Picture gets activated. I assume this is because an M4b could also contain images (and maybe video?).
So I tried to disable Picture in Picture:
// Disable Picture in Picture Mode in iOS
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(MediaMoviePlayer.Handle)
If isKindOfClass(AVPlayerViewController, NSClassFromString("AVPlayerViewController")) Then
Declare Sub setAllowsPiP Lib "AVKit" Selector "setAllowsPictureInPicturePlayback:" (Obj As Ptr, yesNo As Boolean)
setAllowsPiP(AVPlayerViewController, False) // Set to False to disable PiP
End If
This disables picture in picture like I wanted, but the audio does not continue in the background. I am not sure if this is a solvable problem. Does somebody have an idea?
Thanks a lot
Fabian