From 43370fe6ffd1291c8302656f8f56d0b7677f0f51 Mon Sep 17 00:00:00 2001 From: Maximilian Szengel Date: Sun, 14 Aug 2016 02:28:19 +0200 Subject: [PATCH] Expose AVPlayerLayer on ASVideoNode (#2028) The playerLayer is needed for picture in picture support on the iPad (AVPictureInPictureController). --- AsyncDisplayKit/ASVideoNode.h | 3 ++- AsyncDisplayKit/ASVideoNode.mm | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/AsyncDisplayKit/ASVideoNode.h b/AsyncDisplayKit/ASVideoNode.h index 039c2126..9223da3f 100644 --- a/AsyncDisplayKit/ASVideoNode.h +++ b/AsyncDisplayKit/ASVideoNode.h @@ -12,7 +12,7 @@ #import #import -@class AVAsset, AVPlayer, AVPlayerItem, AVVideoComposition, AVAudioMix; +@class AVAsset, AVPlayer, AVPlayerLayer, AVPlayerItem, AVVideoComposition, AVAudioMix; @protocol ASVideoNodeDelegate; typedef enum { @@ -51,6 +51,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nullable, nonatomic, strong, readwrite) AVAudioMix *audioMix; @property (nullable, nonatomic, strong, readonly) AVPlayer *player; +@property (nullable, nonatomic, strong, readonly) AVPlayerLayer *playerLayer; @property (nullable, nonatomic, strong, readonly) AVPlayerItem *currentItem; diff --git a/AsyncDisplayKit/ASVideoNode.mm b/AsyncDisplayKit/ASVideoNode.mm index 4fd05f06..008c4b94 100644 --- a/AsyncDisplayKit/ASVideoNode.mm +++ b/AsyncDisplayKit/ASVideoNode.mm @@ -551,6 +551,12 @@ static NSString * const kRate = @"rate"; return _player; } +- (AVPlayerLayer *)playerLayer +{ + ASDN::MutexLocker l(__instanceLock__); + return (AVPlayerLayer *)_playerNode.layer; +} + - (id)delegate{ return _delegate; }