It seems Property NowPlayingItem for MPMusicPlayerController of Type SystemMusicPlayer is completely broken.
In my existing App as well as in a fresh project, these lines of code
var musicPlayerController = MPMusicPlayerController.SystemMusicPlayer;
var x = musicPlayerController.NowPlayingItem;
Leads to this exception:
_ObjCRuntime.RuntimeException: Can't lookup the Objective-C class 0x1cf6e8630 (7522073724) when the dynamic registrar has been linked away.
at ObjCRuntime.Class.LookupClass (System.IntPtr klass, System.Boolean throw_on_error) [0x00067] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/ObjCRuntime/Class.cs:232
at ObjCRuntime.Class.Lookup (System.IntPtr klass) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/ObjCRuntime/Class.cs:203
at ObjCRuntime.Runtime.GetNSObject[T] (System.IntPtr ptr) [0x0003b] in <75e8f2cafde249969958834208668188>:0
at MediaPlayer.MPMusicPlayerController.get_NowPlayingItem () [0x00003] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/MPMusicPlayerController.g.cs:456 _
I tried to fix this exception by adding --optimize=-remove-dynamic-registrar
Now I receive another exception:
_ObjCRuntime.RuntimeException
Message=The ObjectiveC class '_MPMusicPlayerMediaItemProxy' could not be registered, it does not seem to derive from any known ObjectiveC class (including NSObject).
Source=Xamarin.iOS
StackTrace:
at Registrar.DynamicRegistrar.Lookup (System.IntPtr class, System.Boolean throw_on_error) [0x00075] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/ObjCRuntime/DynamicRegistrar.cs:942
at ObjCRuntime.Class.LookupClass (System.IntPtr klass, System.Boolean throw_on_error) [0x00021] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/ObjCRuntime/Class.cs:227
at ObjCRuntime.Class.Lookup (System.IntPtr klass) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/ObjCRuntime/Class.cs:203
at ObjCRuntime.Runtime.GetNSObject[T] (System.IntPtr ptr) [0x0003b] in <75e8f2cafde249969958834208668188>:0
at MediaPlayer.MPMusicPlayerController.get_NowPlayingItem () [0x00003] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/MPMusicPlayerController.g.cs:456 _
Has anybody an idea how to fix this?