Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[WEEX-645][iOS] video can hide controls (#1636)
Browse files Browse the repository at this point in the history
  • Loading branch information
doumafang authored and cxfeng1 committed Oct 16, 2018
1 parent d86ae20 commit 4fe0c41
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions ios/sdk/WeexSDK/Sources/Component/WXVideoComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ @implementation WXPlayer

@interface WXVideoView()

@property (nonatomic, strong) UIViewController* playerViewController;
@property (nonatomic, strong) AVPlayerItem* playerItem;
@property (nonatomic, strong) WXSDKInstance* weexSDKInstance;
@property (nonatomic, strong) UIViewController *playerViewController;
@property (nonatomic, strong) AVPlayerItem *playerItem;
@property (nonatomic, strong) WXSDKInstance *weexSDKInstance;
@property (nonatomic, strong) UIImageView *posterImageView;
@property (nonatomic, strong) id<WXImageOperationProtocol> imageOperation;
@property (nonatomic, assign) BOOL playerDidPlayed;
Expand Down Expand Up @@ -192,7 +192,8 @@ - (void)setURL:(NSURL *)URL
}
}

- (void)setPosterURL:(NSURL *)posterURL {
- (void)setPosterURL:(NSURL *)posterURL
{
if (!posterURL) {
return;
}
Expand All @@ -213,6 +214,19 @@ - (void)setPosterURL:(NSURL *)posterURL {
}];
}

- (void)setControlShow:(BOOL)showControl
{
if ([self greater8SysVer]) {
AVPlayerViewController *AVVC = (AVPlayerViewController*)_playerViewController;
AVVC.showsPlaybackControls = showControl;
}
else
{
MPMoviePlayerViewController *MPVC = (MPMoviePlayerViewController*)_playerViewController;
MPVC.moviePlayer.controlStyle = showControl ? MPMovieControlStyleEmbedded : MPMovieControlStyleNone;
}
}

- (void)playFinish
{
if (_playbackStateChanged)
Expand Down Expand Up @@ -293,6 +307,7 @@ @interface WXVideoComponent()
@property (nonatomic, strong) NSURL *posterURL;
@property (nonatomic) BOOL autoPlay;
@property (nonatomic) BOOL playStatus;
@property (nonatomic) BOOL showControl;

@end

Expand All @@ -316,6 +331,9 @@ - (instancetype)initWithRef:(NSString *)ref type:(NSString *)type styles:(NSDict
if (attributes[@"poster"]) {
_posterURL = [NSURL URLWithString: attributes[@"poster"]];
}
if (attributes[@"controls"]) {
_showControl = ![attributes[@"controls"] isEqualToString:@"controls"];
}
}
return self;
}
Expand All @@ -333,6 +351,7 @@ - (void)viewDidLoad
_videoView.layer.mask = [self drawBorderRadiusMaskLayer:_videoView.bounds];
[_videoView setURL:_videoURL];
[_videoView setPosterURL:_posterURL];
[_videoView setControlShow:_showControl];

__weak __typeof__(self) weakSelf = self;
_videoView.posterClickHandle = ^{
Expand Down Expand Up @@ -370,7 +389,7 @@ - (void)viewDidLoad
}
}

-(void)updateAttributes:(NSDictionary *)attributes
- (void)updateAttributes:(NSDictionary *)attributes
{
if (attributes[@"src"]) {
_videoURL = [NSURL URLWithString: attributes[@"src"]];
Expand All @@ -392,6 +411,10 @@ -(void)updateAttributes:(NSDictionary *)attributes
_posterURL = [NSURL URLWithString: attributes[@"poster"]];
[_videoView setPosterURL:_posterURL];
}
if (attributes[@"controls"]) {
_showControl = ![attributes[@"controls"] isEqualToString:@"controls"];
[_videoView setControlShow:_showControl];
}
}

@end

0 comments on commit 4fe0c41

Please sign in to comment.