sha*_*irh 10 video objective-c ios
有没有人知道任何现有的库,或任何有关如何获得与Youtube应用程序相同的效果的技术.
视频可以"最小化"并悬停在屏幕底部 - 然后可以滑动以关闭或触摸以重新最大化.
看到:
视频播放正常:https://www.dropbox.com/s/o8c1ntfkkp4pc4q/2014-06-07%2001.19.20.png
视频最小化:https://www.dropbox.com/s/w0syp3infu21g08/2014-06-07%2001.19.27.png
(注意视频现在是如何在屏幕右下方的一个小浮动窗口中).
任何人都知道这是如何实现的,如果有任何现有的教程或库可以用来获得同样的效果?
dan*_*anh 17
听起来很有趣,所以我看着youtube.该视频看起来像在顶部的16:9框中播放,下面还有"另请参见"列表.当用户最小化视频时,播放器会与"另请参见"视图一起下降到右下角.与此同时,"看得见"的观点逐渐消失.
1)设置这样的视图并创建出口.这是它在IB中的样子.(注意两个容器是兄弟姐妹)

2)向上滑动视频视图并向下滑动手势识别器:
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIView *tallMpContainer;
@property (weak, nonatomic) IBOutlet UIView *mpContainer;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
UISwipeGestureRecognizer *swipeDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeDown:)];
UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeUp:)];
swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
swipeDown.direction = UISwipeGestureRecognizerDirectionDown;
[self.mpContainer addGestureRecognizer:swipeUp];
[self.mpContainer addGestureRecognizer:swipeDown];
}
- (void)swipeDown:(UIGestureRecognizer *)gr {
[self minimizeMp:YES animated:YES];
}
- (void)swipeUp:(UIGestureRecognizer *)gr {
[self minimizeMp:NO animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
3)然后是一种了解当前状态并改变当前状态的方法.
- (BOOL)mpIsMinimized {
return self.tallMpContainer.frame.origin.y > 0;
}
- (void)minimizeMp:(BOOL)minimized animated:(BOOL)animated {
if ([self mpIsMinimized] == minimized) return;
CGRect tallContainerFrame, containerFrame;
CGFloat tallContainerAlpha;
if (minimized) {
CGFloat mpWidth = 160;
CGFloat mpHeight = 90; // 160:90 == 16:9
CGFloat x = 320-mpWidth;
CGFloat y = self.view.bounds.size.height - mpHeight;
tallContainerFrame = CGRectMake(x, y, 320, self.view.bounds.size.height);
containerFrame = CGRectMake(x, y, mpWidth, mpHeight);
tallContainerAlpha = 0.0;
} else {
tallContainerFrame = self.view.bounds;
containerFrame = CGRectMake(0, 0, 320, 180);
tallContainerAlpha = 1.0;
}
NSTimeInterval duration = (animated)? 0.5 : 0.0;
[UIView animateWithDuration:duration animations:^{
self.tallMpContainer.frame = tallContainerFrame;
self.mpContainer.frame = containerFrame;
self.tallMpContainer.alpha = tallContainerAlpha;
}];
}
Run Code Online (Sandbox Code Playgroud)
我没有向这个项目添加视频,但它应该只是插入.使mpContainer成为MPMoviePlayerController视图的父视图,它看起来应该很酷.