diff --git a/src/avfoundation.cs b/src/avfoundation.cs index 482ab2f5b7..0a1284ad82 100644 --- a/src/avfoundation.cs +++ b/src/avfoundation.cs @@ -60,6 +60,7 @@ using CoreGraphics; using CoreVideo; using UniformTypeIdentifiers; using ImageIO; +using MediaPlayer; using System; #if MONOMAC @@ -12392,6 +12393,10 @@ namespace AVFoundation { [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 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 2abf9191bb..7bc98a00f6 100644 --- a/src/mediaplayer.cs +++ b/src/mediaplayer.cs @@ -14,6 +14,7 @@ using Foundation; using CoreFoundation; using CoreGraphics; using CoreLocation; +using CoreMedia; #if MONOMAC using AppKit; #else @@ -285,6 +286,7 @@ namespace MediaPlayer { [NoMac] [Deprecated (PlatformName.iOS, 10, 0)] + [Deprecated (PlatformName.TvOS, 10, 0)] [Export ("initWithImage:")] NativeHandle Constructor (UIImage image); @@ -297,6 +299,7 @@ namespace MediaPlayer { [NoMac] [Deprecated (PlatformName.iOS, 10, 0)] + [Deprecated (PlatformName.TvOS, 10, 0)] [Export ("imageCropRect")] CGRect ImageCropRectangle { get; } } @@ -768,7 +771,7 @@ namespace MediaPlayer { [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 @@ namespace MediaPlayer { 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 @@ namespace MediaPlayer { 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 @@ namespace MediaPlayer { [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 PropertyCreditsStartTime { get; } } [Mac (10,12,2)] @@ -2280,8 +2297,8 @@ namespace MediaPlayer { 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 @@ namespace MediaPlayer { 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 @@ namespace MediaPlayer { [Export ("removePlayer:")] void RemovePlayer (AVPlayer player); + + [TV (16, 0), NoWatch, NoMacCatalyst, NoMac] + [Export ("automaticallyPublishesNowPlayingInfo")] + bool AutomaticallyPublishesNowPlayingInfo { 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/cecil-tests/AttributeTest.cs b/tests/cecil-tests/AttributeTest.cs index 9f9e3d58bf..267d42bec6 100644 --- a/tests/cecil-tests/AttributeTest.cs +++ b/tests/cecil-tests/AttributeTest.cs @@ -273,8 +273,12 @@ namespace Cecil.Tests { 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 98894b9931..2466df1032 100644 --- a/tests/introspection/ApiSelectorTest.cs +++ b/tests/introspection/ApiSelectorTest.cs @@ -380,6 +380,15 @@ namespace Introspection { return true; } break; +#if __WATCHOS__ + case "AVPlayerItem": + switch (selectorName) { + case "nowPlayingInfo": + case "setNowPlayingInfo:": + return TestRuntime.IsSimulatorOrDesktop; + } + break; +#endif case "AVPlayerItemVideoOutput": switch (selectorName) { case "initWithOutputSettings:": 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 b62e100dc4..0000000000 --- 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::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::setDelegate: not bound -!missing-type! MPAdTimeRange not bound -!missing-type! MPNowPlayingSession not bound -!missing-selector! MPNowPlayingSession::automaticallyPublishesNowPlayingInfo not bound -!missing-selector! MPNowPlayingSession::setAutomaticallyPublishesNowPlayingInfo: 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 05cc330997..0000000000 --- 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 bd3a7bdca9..0000000000 --- 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-type! MPAdTimeRange not bound -!missing-selector! MPNowPlayingSession::automaticallyPublishesNowPlayingInfo not bound -!missing-selector! MPNowPlayingSession::setAutomaticallyPublishesNowPlayingInfo: not bound diff --git a/tests/xtro-sharpie/iOS-MediaPlayer.todo b/tests/xtro-sharpie/iOS-MediaPlayer.todo deleted file mode 100644 index b62e100dc4..0000000000 --- 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::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::setDelegate: not bound -!missing-type! MPAdTimeRange not bound -!missing-type! MPNowPlayingSession not bound -!missing-selector! MPNowPlayingSession::automaticallyPublishesNowPlayingInfo not bound -!missing-selector! MPNowPlayingSession::setAutomaticallyPublishesNowPlayingInfo: not bound diff --git a/tests/xtro-sharpie/macOS-MediaPlayer.todo b/tests/xtro-sharpie/macOS-MediaPlayer.todo deleted file mode 100644 index 05cc330997..0000000000 --- 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 98f639e034..0000000000 --- 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-type! MPAdTimeRange not bound -!missing-selector! MPNowPlayingSession::automaticallyPublishesNowPlayingInfo not bound -!missing-selector! MPNowPlayingSession::setAutomaticallyPublishesNowPlayingInfo: not bound diff --git a/tests/xtro-sharpie/watchOS-MediaPlayer.todo b/tests/xtro-sharpie/watchOS-MediaPlayer.todo deleted file mode 100644 index 05cc330997..0000000000 --- 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