-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathREADME
More file actions
193 lines (134 loc) · 7.34 KB
/
Copy pathREADME
File metadata and controls
193 lines (134 loc) · 7.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
----- Description
We have video timeline control which represents list of video frames.
Timeline consists of 3 moving parts:
- slider
- left part
- right part
----- Init
Call this method to init control:
- (id)initWithFrame:(CGRect)frame fileURL:(NSURL *)fileUrl;
fileUrl - url to the local storage video file
----- Supported Orientations
Portrait and Landscape orientations are supported.
Call this method inside didRotateFromInterfaceOrientation method of ViewController
- (void)reloadTimelineInCurrentInterfaceOrientation;
----- Manipulation
We have ability to manipulate behavior of control via 3 properties:
1)
@property (nonatomic, assign) BOOL editing;
Set left and right parts moved or unmoved.
When you moving left or right part of control and part go to the next thumbnail on timeline this methods will be called:
- (void) timelineControl:(TimelineControl *)control startThumbnailChanged:(CMTime)time; // for left part
- (void) timelineControl:(TimelineControl *)control endThumbnailChanged:(CMTime)time; // for right part
When you stop moving left or right part of the control and hold on finger on the timeline, this methods will be called.
- (void) timelineControl:(TimelineControl *)control startHovered:(CMTime)time;
- (void) timelineControl:(TimelineControl *)control endHovered:(CMTime)time;
2)
@property (nonatomic, assign) BOOL sliderHidden;
This set slider hidden.
If NO: this methods will be called:
- (void) timelineControl:(TimelineControl *)control sliderThumbnailChanged:(CMTime)time;
- (void) timelineControl:(TimelineControl *)control sliderHovered:(CMTime)time;
3)
@property (nonatomic, assign) NSTimeInterval touchedDelayToGenerateNewFrame;
Value of this property influent on time when this methods will be called:
- (void) timelineControl:(TimelineControl *)control sliderHovered:(CMTime)time;
- (void) timelineControl:(TimelineControl *)control startHovered:(CMTime)time;
- (void) timelineControl:(TimelineControl *)control endHovered:(CMTime)time;
----- Delegate
To receive information about interaction with control need set delegate value and realize it methods:
@property (nonatomic, assign) id<TimelineControlDelegate> delegate;
// moving through thumbnails
- (void) timelineControl:(TimelineControl *)control sliderThumbnailChanged:(CMTime)time;
- (void) timelineControl:(TimelineControl *)control startThumbnailChanged:(CMTime)time;
- (void) timelineControl:(TimelineControl *)control endThumbnailChanged:(CMTime)time;
// end of moving
- (void) timelineControl:(TimelineControl *)control sliderMovingEnded:(CMTime)time;
- (void) timelineControl:(TimelineControl *)control startMovingEnded:(CMTime)time;
- (void) timelineControl:(TimelineControl *)control endMovingEnded:(CMTime)time;
// hovering
- (void) timelineControl:(TimelineControl *)control sliderHovered:(CMTime)time;
- (void) timelineControl:(TimelineControl *)control startHovered:(CMTime)time;
- (void) timelineControl:(TimelineControl *)control endHovered:(CMTime)time;
----- Gettin times of moved parts
- (CMTime)timelineSliderTime; // slider time
- (CMTime)timelineStartTime; // start time
- (CMTime)timelineEndTime; // end time
----- Getting images
Recommended use synchronous methods, when you need get only one image.
Not recommended use in real time image extraction synchronous methods.
// synchronously
- (UIImage *)imageForTime:(CMTime)time;
- (UIImage *)imageForTime:(CMTime)time size:(CGSize)size;
- (UIImage *)imageForTime:(CMTime)time width:(NSInteger)width;
- (UIImage *)imageForTime:(CMTime)time height:(NSInteger)height;
// If you need request images very often and need only last result use asynchronous methods.
// asynchronously
- (void)imageForTime:(CMTime)time completionHandler:(void(^)(UIImage *image))completionHandler;
- (void)imageForTime:(CMTime)time size:(CGSize)size completionHandler:(void(^)(UIImage *image))completionHandler;
- (void)imageForTime:(CMTime)time width:(NSInteger)width completionHandler:(void(^)(UIImage *image))completionHandler;
- (void)imageForTime:(CMTime)time height:(NSInteger)height completionHandler:(void(^)(UIImage *image))completionHandler;
Every asynchronous method call stops previously asynchronous calls.
----- Examples
1)
- (id)init {
self = [super init];
if (self) {
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"aaa" ofType:@"MOV"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
_timelineControl = [[TimelineControl alloc] initWithFrame:CGRectMake(0, 0, 320, 60) fileURL:fileURL];
[_timelineControl setDelegate:self];
}
return self;
}
- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
[_timelineControl reloadTimelineInCurrentInterfaceOrientation];
}
// delegate methods
- (void) timelineControl:(TimelineControl *)control sliderThumbnailChanged:(CMTime)time {
int width = CGRectGetWidth(_imageView.frame) * 2;
[_timelineControl imageForTime:time width:width completionHandler:^(UIImage *image) {
[_imageView performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:NO];
}];
}
- (void) timelineControl:(TimelineControl *)control startThumbnailChanged:(CMTime)time {
}
- (void) timelineControl:(TimelineControl *)control endThumbnailChanged:(CMTime)time {
}
- (void) timelineControl:(TimelineControl *)control sliderMovingEnded:(CMTime)time {
int width = CGRectGetWidth(_imageView.frame);
[_timelineControl imageForTime:time width:width completionHandler:^(UIImage *image) {
[_imageView performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:NO];
}];
}
- (void) timelineControl:(TimelineControl *)control startMovingEnded:(CMTime)time {
int width = CGRectGetWidth(_imageView.frame);
[_timelineControl imageForTime:[_timelineControl timelineSliderTime] width:width completionHandler:^(UIImage *image) {
[_imageView performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:NO];
}];
}
- (void) timelineControl:(TimelineControl *)control endMovingEnded:(CMTime)time {
int width = CGRectGetWidth(_imageView.frame);
[_timelineControl imageForTime:[_timelineControl timelineSliderTime] width:width completionHandler:^(UIImage *image) {
[_imageView performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:NO];
}];
}
- (void) timelineControl:(TimelineControl *)control sliderHovered:(CMTime)time {
int width = CGRectGetWidth(_imageView.frame);
[_timelineControl imageForTime:time width:width completionHandler:^(UIImage *image) {
[_imageView performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:NO];
}];
}
- (void) timelineControl:(TimelineControl *)control startHovered:(CMTime)time {
int width = CGRectGetWidth(_imageView.frame);
[_timelineControl imageForTime:time width:width completionHandler:^(UIImage *image) {
[_imageView performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:NO];
}];
}
- (void) timelineControl:(TimelineControl *)control endHovered:(CMTime)time {
int width = CGRectGetWidth(_imageView.frame);
[_timelineControl imageForTime:time width:width completionHandler:^(UIImage *image) {
[_imageView performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:NO];
}];
}