Skip to content

Commit 68f9d29

Browse files
Merge pull request ResearchKit#1396 from Pariecemckinney-apple/video_instruction_fix_issue_1389
Video Instruction Step Now Presents Play Button (ResearchKit#1389)
2 parents 47f44c4 + 24afb1b commit 68f9d29

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

Diff for: ResearchKit/Common/ORKVideoInstructionStepViewController.m

+21-19
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3737
#import "AVFoundation/AVFoundation.h"
3838
#import <AVKit/AVKit.h>
3939
#import "ORKHelpers_Internal.h"
40+
#import "ORKStepContentView.h"
41+
#import "ORKStepContentView_Private.h"
4042

4143

4244
@interface ORKRateObservedPlayer : AVPlayer
@@ -79,25 +81,25 @@ - (void)stepDidChange {
7981
[super stepDidChange];
8082
_playbackStoppedTime = NAN;
8183
_playbackCompleted = NO;
82-
//FIXME: video instruction step needs to adopt ORKInstructionStepContainerView
83-
// if (self.step && [self isViewLoaded] && [self videoInstructionStep].image) {
84-
// UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] init];
85-
// [tapRecognizer addTarget:self action:@selector(play)];
86-
// [self.stepView.instructionImageView addGestureRecognizer:tapRecognizer];
87-
//
88-
// if (self.stepView.instructionImageView.image) {
89-
// UIImageView *playImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"play" inBundle:ORKBundle() compatibleWithTraitCollection:nil]];
90-
// self.stepView.instructionImageView.userInteractionEnabled = YES;
91-
// [self.stepView.instructionImageView addSubview:playImageView];
92-
//
93-
// playImageView.translatesAutoresizingMaskIntoConstraints = NO;
94-
//
95-
// NSLayoutConstraint* xConstraint = [NSLayoutConstraint constraintWithItem:self.stepView.instructionImageView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:playImageView attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
96-
// NSLayoutConstraint* yConstraint = [NSLayoutConstraint constraintWithItem:self.stepView.instructionImageView attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:playImageView attribute:NSLayoutAttributeCenterY multiplier:1 constant:0];
97-
//
98-
// [self.stepView.instructionImageView addConstraints:@[xConstraint, yConstraint]];
99-
// }
100-
// }
84+
85+
if (self.step && [self isViewLoaded] && [self videoInstructionStep].image) {
86+
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] init];
87+
[tapRecognizer addTarget:self action:@selector(play)];
88+
[self.stepView.stepContentView.topContentImageView addGestureRecognizer:tapRecognizer];
89+
90+
if (self.stepView.stepContentView.topContentImageView) {
91+
UIImageView *playImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"play" inBundle:ORKBundle() compatibleWithTraitCollection:nil]];
92+
self.stepView.stepContentView.topContentImageView.userInteractionEnabled = YES;
93+
[self.stepView.stepContentView.topContentImageView addSubview:playImageView];
94+
95+
playImageView.translatesAutoresizingMaskIntoConstraints = NO;
96+
97+
NSLayoutConstraint* xConstraint = [NSLayoutConstraint constraintWithItem:self.stepView.stepContentView.topContentImageView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:playImageView attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
98+
NSLayoutConstraint* yConstraint = [NSLayoutConstraint constraintWithItem:self.stepView.stepContentView.topContentImageView attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:playImageView attribute:NSLayoutAttributeCenterY multiplier:1 constant:0];
99+
100+
[self.stepView.stepContentView.topContentImageView addConstraints:@[xConstraint, yConstraint]];
101+
}
102+
}
101103
}
102104

103105
- (void)setThumbnailImageFromAsset {

0 commit comments

Comments
 (0)