2015-10-01 18:19:52 +02:00
|
|
|
#import "TGModernGalleryVideoView.h"
|
|
|
|
#import <AVFoundation/AVFoundation.h>
|
|
|
|
|
|
|
|
@interface TGModernGalleryVideoView ()
|
|
|
|
{
|
|
|
|
AVPlayerLayer *_playerLayer;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation TGModernGalleryVideoView
|
|
|
|
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame player:(AVPlayer *)player
|
|
|
|
{
|
|
|
|
self = [super initWithFrame:frame];
|
|
|
|
if (self != nil)
|
|
|
|
{
|
|
|
|
self.playerLayer.player = player;
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2016-02-25 01:03:51 +01:00
|
|
|
- (void)dealloc
|
|
|
|
{
|
|
|
|
void (^deallocBlock)(void) = self.deallocBlock;
|
|
|
|
if (deallocBlock != nil)
|
|
|
|
deallocBlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)cleanupPlayer
|
|
|
|
{
|
|
|
|
self.playerLayer.player = nil;
|
|
|
|
}
|
|
|
|
|
2015-10-01 18:19:52 +02:00
|
|
|
+ (Class)layerClass
|
|
|
|
{
|
|
|
|
return [AVPlayerLayer class];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (AVPlayerLayer *)playerLayer
|
|
|
|
{
|
|
|
|
return (AVPlayerLayer *)self.layer;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|