From e1b7ec3b2e9ae9fdf682875aab0a7ff6590cfa92 Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Sat, 6 Aug 2022 15:38:18 -0400 Subject: [PATCH 1/4] [Mediaplayer] Add support for xcode14 bet 4. --- src/avfoundation.cs | 5 +++ src/mediaplayer.cs | 45 ++++++++++++++++--- .../iOS-MediaPlayer.todo | 23 ---------- .../macOS-MediaPlayer.todo | 4 -- .../tvOS-MediaPlayer.todo | 21 --------- tests/xtro-sharpie/iOS-MediaPlayer.todo | 23 ---------- tests/xtro-sharpie/macOS-MediaPlayer.todo | 4 -- tests/xtro-sharpie/tvOS-MediaPlayer.todo | 10 ----- tests/xtro-sharpie/watchOS-MediaPlayer.todo | 4 -- 9 files changed, 45 insertions(+), 94 deletions(-) delete mode 100644 tests/xtro-sharpie/api-annotations-dotnet/iOS-MediaPlayer.todo delete mode 100644 tests/xtro-sharpie/api-annotations-dotnet/macOS-MediaPlayer.todo delete mode 100644 tests/xtro-sharpie/api-annotations-dotnet/tvOS-MediaPlayer.todo delete mode 100644 tests/xtro-sharpie/iOS-MediaPlayer.todo delete mode 100644 tests/xtro-sharpie/macOS-MediaPlayer.todo delete mode 100644 tests/xtro-sharpie/tvOS-MediaPlayer.todo delete mode 100644 tests/xtro-sharpie/watchOS-MediaPlayer.todo diff --git a/src/avfoundation.cs b/src/avfoundation.cs index 482ab2f5b76e..09422b2c9098 100644 --- a/src/avfoundation.cs +++ b/src/avfoundation.cs @@ -60,6 +60,7 @@ using CoreVideo; using UniformTypeIdentifiers; using ImageIO; +using MediaPlayer; using System; #if MONOMAC @@ -12392,6 +12393,10 @@ interface AVPlayerItem : NSCopying { [TV (15, 0), NoWatch, NoMac, NoiOS, NoMacCatalyst] [Export ("translatesPlayerInterstitialEvents")] bool TranslatesPlayerInterstitialEvents { get; set; } + + [Watch (9, 0), TV (16, 0), Mac (13, 0), iOS (16, 0)] + [NullAllowed, Export ("nowPlayingInfo", ArgumentSemantic.Copy)] + NSDictionary NowPlayingInfo { get; set; } } [Watch (7,4), TV (14,5), Mac (11,3), iOS (14,5)] diff --git a/src/mediaplayer.cs b/src/mediaplayer.cs index 2abf9191bb81..f8ed25d52367 100644 --- a/src/mediaplayer.cs +++ b/src/mediaplayer.cs @@ -14,6 +14,7 @@ using CoreFoundation; using CoreGraphics; using CoreLocation; +using CoreMedia; #if MONOMAC using AppKit; #else @@ -285,6 +286,7 @@ interface MPMediaItemArtwork { [NoMac] [Deprecated (PlatformName.iOS, 10, 0)] + [Deprecated (PlatformName.TvOS, 10, 0)] [Export ("initWithImage:")] NativeHandle Constructor (UIImage image); @@ -297,6 +299,7 @@ interface MPMediaItemArtwork { [NoMac] [Deprecated (PlatformName.iOS, 10, 0)] + [Deprecated (PlatformName.TvOS, 10, 0)] [Export ("imageCropRect")] CGRect ImageCropRectangle { get; } } @@ -768,7 +771,7 @@ interface MPMoviePlayerTimedMetadataEventArgs { [NoMac] #if NET [NoWatch] // marked as unavailable in xcode 12 beta 1 - [NoTV] + [TV (16,0)] #else [Watch (5,0)] [Obsoleted (PlatformName.TvOS, 14,0, message: "Removed in Xcode 12.")] @@ -1306,6 +1309,7 @@ interface MPVolumeView { NativeHandle Constructor (CGRect frame); [Deprecated (PlatformName.iOS, 13, 0, message: "Use 'AVRoutePickerView' instead.")] + [Deprecated (PlatformName.TvOS, 13, 0, message: "Use 'AVRoutePickerView' instead.")] [Export ("showsRouteButton")] bool ShowsRouteButton { get; set; } @@ -1342,25 +1346,30 @@ interface MPVolumeView { CGRect GetVolumeThumbRect (CGRect bounds, CGRect columeSliderRect, float /* float, not CGFloat */ value); [Deprecated (PlatformName.iOS, 13, 0, message: "Use 'AVRoutePickerView.RoutePickerButtonStyle' instead.")] + [Deprecated (PlatformName.TvOS, 13, 0, message: "Use 'AVRoutePickerView.RoutePickerButtonStyle' instead.")] [Export ("setRouteButtonImage:forState:")] void SetRouteButtonImage ([NullAllowed] UIImage image, UIControlState state); [Deprecated (PlatformName.iOS, 13, 0, message: "See 'AVRoutePickerView' for possible replacements.")] + [Deprecated (PlatformName.TvOS, 13, 0, message: "See 'AVRoutePickerView' for possible replacements.")] [return: NullAllowed] [Export ("routeButtonImageForState:")] UIImage GetRouteButtonImage (UIControlState state); [Deprecated (PlatformName.iOS, 13, 0, message: "See 'AVRoutePickerView' for possible replacements.")] + [Deprecated (PlatformName.TvOS, 13, 0, message: "See 'AVRoutePickerView' for possible replacements.")] [Export ("routeButtonRectForBounds:")] CGRect GetRouteButtonRect (CGRect bounds); [iOS (7,0)] [Deprecated (PlatformName.iOS, 13, 0, message: "Use 'AVRouteDetector.MultipleRoutesDetected' instead.")] + [Deprecated (PlatformName.TvOS, 13, 0, message: "Use 'AVRouteDetector.MultipleRoutesDetected' instead.")] [Export ("wirelessRoutesAvailable")] bool AreWirelessRoutesAvailable { [Bind ("areWirelessRoutesAvailable")] get; } [iOS (7,0)] [Deprecated (PlatformName.iOS, 13, 0, message: "Use 'AVPlayer.ExternalPlaybackActive' instead.")] + [Deprecated (PlatformName.TvOS, 13, 0, message: "Use 'AVPlayer.ExternalPlaybackActive' instead.")] [Export ("wirelessRouteActive")] bool IsWirelessRouteActive { [Bind ("isWirelessRouteActive")] get; } @@ -1499,6 +1508,14 @@ interface MPNowPlayingInfoCenter { [Internal] [Field ("MPNowPlayingInfoPropertyCurrentPlaybackDate")] NSString PropertyCurrentPlaybackDate { get; } + + [TV (16, 0), Mac (13, 0), iOS (16, 0), MacCatalyst (16,0), Watch (9,0)] + [Field ("MPNowPlayingInfoPropertyAdTimeRanges")] + NSString PropertyAdTimeRanges { get; } + + [TV (16, 0), Mac (13, 0), iOS (16, 0), MacCatalyst (16,0), Watch (9,0)] + [Field ("MPNowPlayingInfoPropertyCreditsStartTime")] + NSString MPNowPlayingInfoPropertyCreditsStartTime { get; } } [Mac (10,12,2)] @@ -2280,8 +2297,8 @@ interface AVMediaSelectionGroup_MPNowPlayingInfoLanguageOptionAdditions { interface IMPNowPlayingSessionDelegate {} - [TV (14,0)] - [NoWatch, NoMac, NoiOS] + [TV (14,0), iOS (16,0)] + [NoWatch, NoMac, NoMacCatalyst] #if NET [Protocol, Model] #else @@ -2297,8 +2314,8 @@ interface MPNowPlayingSessionDelegate { void DidChangeCanBecomeActive (MPNowPlayingSession nowPlayingSession); } - [TV (14,0)] - [NoWatch, NoMac, NoiOS] + [TV (14,0), iOS (16,0)] + [NoWatch, NoMac, NoMacCatalyst] [BaseType (typeof (NSObject))] [DisableDefaultCtor] interface MPNowPlayingSession { @@ -2337,5 +2354,23 @@ interface MPNowPlayingSession { [Export ("removePlayer:")] void RemovePlayer (AVPlayer player); + + [TV (16, 0), NoWatch, NoMacCatalyst, NoMac] + [Export ("automaticallyPublishNowPlayingInfo")] + bool AutomaticallyPublishNowPlayingInfo { get; set; } + } + + [TV (16,0), NoWatch, NoMacCatalyst, NoMac, iOS (16,0)] + [BaseType (typeof (NSObject))] + [DisableDefaultCtor] + interface MPAdTimeRange : NSCopying + { + [Export ("timeRange", ArgumentSemantic.Assign)] + CMTimeRange TimeRange { get; set; } + + [Export ("initWithTimeRange:")] + NativeHandle Constructor (CMTimeRange timeRange); } + + } diff --git a/tests/xtro-sharpie/api-annotations-dotnet/iOS-MediaPlayer.todo b/tests/xtro-sharpie/api-annotations-dotnet/iOS-MediaPlayer.todo deleted file mode 100644 index dc63594c52bd..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/iOS-MediaPlayer.todo +++ /dev/null @@ -1,23 +0,0 @@ -!missing-field! MPNowPlayingInfoPropertyAdTimeRanges not bound -!missing-field! MPNowPlayingInfoPropertyCreditsStartTime not bound -!missing-protocol! MPNowPlayingSessionDelegate not bound -!missing-selector! AVPlayerItem::nowPlayingInfo not bound -!missing-selector! AVPlayerItem::setNowPlayingInfo: not bound -!missing-selector! MPAdTimeRange::initWithTimeRange: not bound -!missing-selector! MPAdTimeRange::setTimeRange: not bound -!missing-selector! MPAdTimeRange::timeRange not bound -!missing-selector! MPNowPlayingSession::addPlayer: not bound -!missing-selector! MPNowPlayingSession::automaticallyPublishNowPlayingInfo not bound -!missing-selector! MPNowPlayingSession::becomeActiveIfPossibleWithCompletion: not bound -!missing-selector! MPNowPlayingSession::canBecomeActive not bound -!missing-selector! MPNowPlayingSession::delegate not bound -!missing-selector! MPNowPlayingSession::initWithPlayers: not bound -!missing-selector! MPNowPlayingSession::isActive not bound -!missing-selector! MPNowPlayingSession::nowPlayingInfoCenter not bound -!missing-selector! MPNowPlayingSession::players not bound -!missing-selector! MPNowPlayingSession::remoteCommandCenter not bound -!missing-selector! MPNowPlayingSession::removePlayer: not bound -!missing-selector! MPNowPlayingSession::setAutomaticallyPublishNowPlayingInfo: not bound -!missing-selector! MPNowPlayingSession::setDelegate: not bound -!missing-type! MPAdTimeRange not bound -!missing-type! MPNowPlayingSession not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/macOS-MediaPlayer.todo b/tests/xtro-sharpie/api-annotations-dotnet/macOS-MediaPlayer.todo deleted file mode 100644 index 05cc3309976a..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/macOS-MediaPlayer.todo +++ /dev/null @@ -1,4 +0,0 @@ -!missing-field! MPNowPlayingInfoPropertyAdTimeRanges not bound -!missing-field! MPNowPlayingInfoPropertyCreditsStartTime not bound -!missing-selector! AVPlayerItem::nowPlayingInfo not bound -!missing-selector! AVPlayerItem::setNowPlayingInfo: not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/tvOS-MediaPlayer.todo b/tests/xtro-sharpie/api-annotations-dotnet/tvOS-MediaPlayer.todo deleted file mode 100644 index aeb1d7cd4e61..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/tvOS-MediaPlayer.todo +++ /dev/null @@ -1,21 +0,0 @@ -!deprecated-attribute-missing! MPMediaItemArtwork::imageCropRect missing a [Deprecated] attribute -!deprecated-attribute-missing! MPMediaItemArtwork::initWithImage: missing a [Deprecated] attribute -!deprecated-attribute-missing! MPVolumeView::areWirelessRoutesAvailable missing a [Deprecated] attribute -!deprecated-attribute-missing! MPVolumeView::isWirelessRouteActive missing a [Deprecated] attribute -!deprecated-attribute-missing! MPVolumeView::routeButtonImageForState: missing a [Deprecated] attribute -!deprecated-attribute-missing! MPVolumeView::routeButtonRectForBounds: missing a [Deprecated] attribute -!deprecated-attribute-missing! MPVolumeView::setRouteButtonImage:forState: missing a [Deprecated] attribute -!deprecated-attribute-missing! MPVolumeView::setShowsRouteButton: missing a [Deprecated] attribute -!deprecated-attribute-missing! MPVolumeView::showsRouteButton missing a [Deprecated] attribute -!missing-protocol! MPMediaPlayback not bound -!missing-protocol-conformance! MPMusicPlayerController should conform to MPMediaPlayback -!missing-field! MPNowPlayingInfoPropertyAdTimeRanges not bound -!missing-field! MPNowPlayingInfoPropertyCreditsStartTime not bound -!missing-selector! AVPlayerItem::nowPlayingInfo not bound -!missing-selector! AVPlayerItem::setNowPlayingInfo: not bound -!missing-selector! MPAdTimeRange::initWithTimeRange: not bound -!missing-selector! MPAdTimeRange::setTimeRange: not bound -!missing-selector! MPAdTimeRange::timeRange not bound -!missing-selector! MPNowPlayingSession::automaticallyPublishNowPlayingInfo not bound -!missing-selector! MPNowPlayingSession::setAutomaticallyPublishNowPlayingInfo: not bound -!missing-type! MPAdTimeRange not bound diff --git a/tests/xtro-sharpie/iOS-MediaPlayer.todo b/tests/xtro-sharpie/iOS-MediaPlayer.todo deleted file mode 100644 index dc63594c52bd..000000000000 --- a/tests/xtro-sharpie/iOS-MediaPlayer.todo +++ /dev/null @@ -1,23 +0,0 @@ -!missing-field! MPNowPlayingInfoPropertyAdTimeRanges not bound -!missing-field! MPNowPlayingInfoPropertyCreditsStartTime not bound -!missing-protocol! MPNowPlayingSessionDelegate not bound -!missing-selector! AVPlayerItem::nowPlayingInfo not bound -!missing-selector! AVPlayerItem::setNowPlayingInfo: not bound -!missing-selector! MPAdTimeRange::initWithTimeRange: not bound -!missing-selector! MPAdTimeRange::setTimeRange: not bound -!missing-selector! MPAdTimeRange::timeRange not bound -!missing-selector! MPNowPlayingSession::addPlayer: not bound -!missing-selector! MPNowPlayingSession::automaticallyPublishNowPlayingInfo not bound -!missing-selector! MPNowPlayingSession::becomeActiveIfPossibleWithCompletion: not bound -!missing-selector! MPNowPlayingSession::canBecomeActive not bound -!missing-selector! MPNowPlayingSession::delegate not bound -!missing-selector! MPNowPlayingSession::initWithPlayers: not bound -!missing-selector! MPNowPlayingSession::isActive not bound -!missing-selector! MPNowPlayingSession::nowPlayingInfoCenter not bound -!missing-selector! MPNowPlayingSession::players not bound -!missing-selector! MPNowPlayingSession::remoteCommandCenter not bound -!missing-selector! MPNowPlayingSession::removePlayer: not bound -!missing-selector! MPNowPlayingSession::setAutomaticallyPublishNowPlayingInfo: not bound -!missing-selector! MPNowPlayingSession::setDelegate: not bound -!missing-type! MPAdTimeRange not bound -!missing-type! MPNowPlayingSession not bound diff --git a/tests/xtro-sharpie/macOS-MediaPlayer.todo b/tests/xtro-sharpie/macOS-MediaPlayer.todo deleted file mode 100644 index 05cc3309976a..000000000000 --- a/tests/xtro-sharpie/macOS-MediaPlayer.todo +++ /dev/null @@ -1,4 +0,0 @@ -!missing-field! MPNowPlayingInfoPropertyAdTimeRanges not bound -!missing-field! MPNowPlayingInfoPropertyCreditsStartTime not bound -!missing-selector! AVPlayerItem::nowPlayingInfo not bound -!missing-selector! AVPlayerItem::setNowPlayingInfo: not bound diff --git a/tests/xtro-sharpie/tvOS-MediaPlayer.todo b/tests/xtro-sharpie/tvOS-MediaPlayer.todo deleted file mode 100644 index 537fc7404add..000000000000 --- a/tests/xtro-sharpie/tvOS-MediaPlayer.todo +++ /dev/null @@ -1,10 +0,0 @@ -!missing-field! MPNowPlayingInfoPropertyAdTimeRanges not bound -!missing-field! MPNowPlayingInfoPropertyCreditsStartTime not bound -!missing-selector! AVPlayerItem::nowPlayingInfo not bound -!missing-selector! AVPlayerItem::setNowPlayingInfo: not bound -!missing-selector! MPAdTimeRange::initWithTimeRange: not bound -!missing-selector! MPAdTimeRange::setTimeRange: not bound -!missing-selector! MPAdTimeRange::timeRange not bound -!missing-selector! MPNowPlayingSession::automaticallyPublishNowPlayingInfo not bound -!missing-selector! MPNowPlayingSession::setAutomaticallyPublishNowPlayingInfo: not bound -!missing-type! MPAdTimeRange not bound diff --git a/tests/xtro-sharpie/watchOS-MediaPlayer.todo b/tests/xtro-sharpie/watchOS-MediaPlayer.todo deleted file mode 100644 index 05cc3309976a..000000000000 --- a/tests/xtro-sharpie/watchOS-MediaPlayer.todo +++ /dev/null @@ -1,4 +0,0 @@ -!missing-field! MPNowPlayingInfoPropertyAdTimeRanges not bound -!missing-field! MPNowPlayingInfoPropertyCreditsStartTime not bound -!missing-selector! AVPlayerItem::nowPlayingInfo not bound -!missing-selector! AVPlayerItem::setNowPlayingInfo: not bound From f947867430fd308480ca608b061ca6d7f10c5f09 Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Sun, 7 Aug 2022 13:52:26 -0400 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: Alex Soto --- src/avfoundation.cs | 2 +- src/mediaplayer.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/avfoundation.cs b/src/avfoundation.cs index 09422b2c9098..0a1284ad82d3 100644 --- a/src/avfoundation.cs +++ b/src/avfoundation.cs @@ -12396,7 +12396,7 @@ interface AVPlayerItem : NSCopying { [Watch (9, 0), TV (16, 0), Mac (13, 0), iOS (16, 0)] [NullAllowed, Export ("nowPlayingInfo", ArgumentSemantic.Copy)] - NSDictionary NowPlayingInfo { get; set; } + NSDictionary WeakNowPlayingInfo { get; set; } } [Watch (7,4), TV (14,5), Mac (11,3), iOS (14,5)] diff --git a/src/mediaplayer.cs b/src/mediaplayer.cs index f8ed25d52367..7dc1f000f5aa 100644 --- a/src/mediaplayer.cs +++ b/src/mediaplayer.cs @@ -1515,7 +1515,7 @@ interface MPNowPlayingInfoCenter { [TV (16, 0), Mac (13, 0), iOS (16, 0), MacCatalyst (16,0), Watch (9,0)] [Field ("MPNowPlayingInfoPropertyCreditsStartTime")] - NSString MPNowPlayingInfoPropertyCreditsStartTime { get; } + NSString PropertyCreditsStartTime { get; } } [Mac (10,12,2)] From f7a880eb5de4a9a8d294a402fd40928b26ac63cd Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Mon, 8 Aug 2022 11:18:02 -0400 Subject: [PATCH 3/4] Fix some test issues. --- tests/cecil-tests/AttributeTest.cs | 8 ++++++-- tests/introspection/ApiSelectorTest.cs | 9 +++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/cecil-tests/AttributeTest.cs b/tests/cecil-tests/AttributeTest.cs index 9f9e3d58bf47..267d42bec69d 100644 --- a/tests/cecil-tests/AttributeTest.cs +++ b/tests/cecil-tests/AttributeTest.cs @@ -273,8 +273,12 @@ static bool IgnoreElementsThatDoNotExistInThatAssembly (string member) return true; } // Generator Bug - Protocol inline with different attribute bug - if (member.StartsWith ("SceneKit.SCNLayer") || - member.StartsWith ("AVFoundation.AVAudioSession")) { + switch (member) { + case string s when s.StartsWith("SceneKit.SCNLayer"): + return true; + case string s when s.StartsWith("AVFoundation.AVAudioSession"): + return true; + case string s when s.StartsWith("MediaPlayer.MPMoviePlayerController"): return true; } switch (member) { diff --git a/tests/introspection/ApiSelectorTest.cs b/tests/introspection/ApiSelectorTest.cs index 01e462e73461..cc8492a82a42 100644 --- a/tests/introspection/ApiSelectorTest.cs +++ b/tests/introspection/ApiSelectorTest.cs @@ -380,6 +380,15 @@ protected virtual bool Skip (Type type, string selectorName) return true; } break; +#if __WATCHOS__ + case "AVPlayerItem": + switch (selectorName) { + case "nowPlayingInfo": + case "setNowPlayingInfo:": + return TestRuntime.IsSimulatorOrDesktop; + } + break; +#endif case "AVPlayerItemVideoOutput": switch (selectorName) { case "initWithOutputSettings:": From 4e3c8388ec9568d0ca6dbc3e80c2c9902a6fc3de Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Thu, 18 Aug 2022 16:46:39 -0400 Subject: [PATCH 4/4] Update API to xcode14 beta5. --- src/mediaplayer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mediaplayer.cs b/src/mediaplayer.cs index 7dc1f000f5aa..7bc98a00f613 100644 --- a/src/mediaplayer.cs +++ b/src/mediaplayer.cs @@ -2356,8 +2356,8 @@ interface MPNowPlayingSession { void RemovePlayer (AVPlayer player); [TV (16, 0), NoWatch, NoMacCatalyst, NoMac] - [Export ("automaticallyPublishNowPlayingInfo")] - bool AutomaticallyPublishNowPlayingInfo { get; set; } + [Export ("automaticallyPublishesNowPlayingInfo")] + bool AutomaticallyPublishesNowPlayingInfo { get; set; } } [TV (16,0), NoWatch, NoMacCatalyst, NoMac, iOS (16,0)]