Skip to content

Commit c12edbd

Browse files
authored
Update moviePlayerExample by using the storyboard (#7887)
#changelog #ios
1 parent f935448 commit c12edbd

8 files changed

Lines changed: 191 additions & 1005 deletions

examples/ios/moviePlayerExample/src/VideoPlayerControls.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77

88
#import <UIKit/UIKit.h>
9+
#import "VideoPlayerControlsDelegateForOF.h"
910

1011
@protocol VideoPlayerControlsDelegate <NSObject>
1112
- (void)playPressed;
@@ -23,12 +24,11 @@
2324
- (void)muteOffPressed;
2425
@end
2526

26-
@interface VideoPlayerControls : UIViewController <UIGestureRecognizerDelegate> {
27-
id<VideoPlayerControlsDelegate> delegate;
27+
@interface VideoPlayerControls : UIViewController {
28+
ofApp * app;
29+
id<VideoPlayerControlsDelegate> delegate;
2830
}
2931

30-
@property(nonatomic, assign) id delegate;
31-
3232
- (void)setPlay:(BOOL)bPlay;
3333
- (void)setNative:(BOOL)bNative;
3434
- (void)setLoop:(BOOL)bLoop;

examples/ios/moviePlayerExample/src/VideoPlayerControls.m

Lines changed: 17 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
static NSString * kMuteOffButtonLabelText = @"MUTE OFF";
2020

2121
@interface VideoPlayerControls () {
22-
IBOutlet UIView * cover;
23-
IBOutlet UIView * controls;
2422
IBOutlet UIButton * playPauseButton;
2523
IBOutlet UIButton * loadButton;
2624
IBOutlet UIButton * loopButton;
@@ -40,56 +38,20 @@ @interface VideoPlayerControls () {
4038

4139
@implementation VideoPlayerControls
4240

43-
@synthesize delegate;
44-
45-
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
46-
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
47-
if (self) {
48-
bShow = YES;
49-
}
50-
return self;
51-
}
52-
5341
- (void)dealloc {
54-
[cover release];
55-
[controls release];
56-
[playPauseButton release];
57-
[loadButton release];
58-
[loopButton release];
59-
[nativeButton release];
60-
[muteButton release];
61-
[slider release];
62-
[timeLabel release];
63-
[topLabel release];
64-
[bottomLabel release];
65-
[newFrameLabel release];
66-
67-
[super dealloc];
42+
6843
}
6944

7045
- (void)viewDidLoad {
7146
[super viewDidLoad];
72-
47+
app = (ofApp*)ofGetAppPtr();
7348
[self setLoad:YES];
7449
[self setPlay:YES];
7550
[self setNative:NO];
7651
[self setLoop:NO];
77-
52+
delegate = [[VideoPlayerControlsDelegateForOF alloc] initWithApp:app];
7853
CGRect screenRect = [UIScreen mainScreen].bounds;
7954
self.view.frame = screenRect;
80-
81-
controlsFrameShow = controls.frame;
82-
controlsFrameShow.origin.y = screenRect.size.height - controlsFrameShow.size.height;
83-
controlsFrameHide = controlsFrameShow;
84-
if(screenRect.size.height <= 640) {
85-
controlsFrameHide.origin.y += controlsFrameHide.size.height;
86-
}
87-
88-
UITapGestureRecognizer * tapGesture;
89-
tapGesture = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureRecognised:)] autorelease];
90-
tapGesture.numberOfTapsRequired = 1;
91-
tapGesture.delegate = self;
92-
[cover addGestureRecognizer:tapGesture];
9355
}
9456

9557
- (void)viewDidUnload {
@@ -191,82 +153,63 @@ - (IBAction)playPauseButtonPressed:(id)sender {
191153
UIButton * button = (UIButton *)sender;
192154

193155
if([button.titleLabel.text isEqualToString:kPauseButtonLabelText]) {
194-
[self.delegate pausePressed];
156+
[self->delegate pausePressed];
195157
} else if([button.titleLabel.text isEqualToString:kPlayButtonLabelText]) {
196-
[self.delegate playPressed];
158+
[self->delegate playPressed];
197159
}
198160
}
199161

200162
- (IBAction)scrubBegin:(id)sender {
201-
[self.delegate scrubBegin];
163+
[self->delegate scrubBegin];
202164
}
203165

204166
- (IBAction)scrub:(id)sender {
205167
float position = slider.value;
206-
[self.delegate scrubToPosition:position];
168+
[self->delegate scrubToPosition:position];
207169
}
208170

209171
- (IBAction)scrubEnd:(id)sender {
210-
[self.delegate scrubEnd];
172+
[self->delegate scrubEnd];
211173
}
212174

213175
- (IBAction)loadButtonPressed:(id)sender {
214176
UIButton * button = (UIButton *)sender;
215177

216178
if([button.titleLabel.text isEqualToString:kLoadButtonLabelText]) {
217-
[self.delegate loadPressed];
179+
[self->delegate loadPressed];
218180
} else if([button.titleLabel.text isEqualToString:kUnloadButtonLabelText]) {
219-
[self.delegate unloadPressed];
181+
[self->delegate unloadPressed];
220182
}
221183
}
222184

223185
- (IBAction)loopButtonPressed:(id)sender {
224186
UIButton * button = (UIButton *)sender;
225187

226188
if([button.titleLabel.text isEqualToString:kLoopOffButtonLabelText]) {
227-
[self.delegate loopOnPressed];
189+
[self->delegate loopOnPressed];
228190
} else if([button.titleLabel.text isEqualToString:kLoopOnButtonLabelText]) {
229-
[self.delegate loopOffPressed];
191+
[self->delegate loopOffPressed];
230192
}
231193
}
232194

233195
- (IBAction)nativeButtonPressed:(id)sender {
234196
UIButton * button = (UIButton *)sender;
235-
197+
236198
if([button.titleLabel.text isEqualToString:kNativeOffButtonLabelText]) {
237-
[self.delegate nativeOnPressed];
199+
[self->delegate nativeOnPressed];
238200
} else if([button.titleLabel.text isEqualToString:kNativeOnButtonLabelText]) {
239-
[self.delegate nativeOffPressed];
201+
[self->delegate nativeOffPressed];
240202
}
241203
}
242204

243205
- (IBAction)muteButtonPressed:(id)sender {
244206
UIButton * button = (UIButton *)sender;
245207

246208
if([button.titleLabel.text isEqualToString:kMuteOffButtonLabelText]) {
247-
[self.delegate muteOnPressed];
209+
[self->delegate muteOnPressed];
248210
} else if([button.titleLabel.text isEqualToString:kMuteOnButtonLabelText]) {
249-
[self.delegate muteOffPressed];
211+
[self->delegate muteOffPressed];
250212
}
251213
}
252214

253-
//-----------------------------------------------------
254-
- (void)tapGestureRecognised:(id)sender {
255-
bShow = !bShow;
256-
if(bShow) {
257-
[UIView animateWithDuration:0.3 animations:^{
258-
controls.frame = controlsFrameShow;
259-
}];
260-
} else {
261-
[UIView animateWithDuration:0.3 animations:^{
262-
controls.frame = controlsFrameHide;
263-
}];
264-
}
265-
}
266-
267-
//-----------------------------------------------------
268-
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
269-
return (interfaceOrientation == UIInterfaceOrientationPortrait);
270-
}
271-
272215
@end

0 commit comments

Comments
 (0)