Instagram直播直播助手怎么录屏屏

1 iOS ReplayKit 录屏SDK 说明 (按照苹果官方的说法是App端加入这些苹果的新特性新SDK更容易被苹果推荐 )
ReplayKit是苹果在iOS9上面提供的一个库组件,可以让玩家在游戏中录制游戏视频,并且可以添加语音评论,然后通过社交网络分享出去。
2库的特性说明
要使用ReplayKit需要在工程的Build Phase的Link binary with libraries中加入ReplayKit.framework.
目前这个库只支持真机允许,不支持模拟器。
系统版本如果低于iOS9也不支持。
还有这个库支持游戏录屏,但不支持录avplayer播放的视频,这个可能是为了保护视频的版权,避免影视资源被复制拷贝。
视频录制完成之后可以调用ReplayKit的接口显示视频预览页面,对应的接口是返回一个页面的ViewController,至于如何显示这个页面,各个客户端可以自由处理,Demo中只是给了其中一种实现方法。
3库的潜在问题
经过实验,发现ReplayKit有如下情况:
录制的启动初始化有时很慢,有见过几十秒才初始化完成的,也碰见过初始化没有成功的。
录制调用了停止接口后系统还会继续录制多几秒的视频。
出现过录制结果为黑屏的情况。
还有这个录屏SDK支付使用麦克风,即是可以一边录制游戏,一边用麦克风讲解。
附件是Demo的工程,使用Xcode7编译之后可以运行起来(不支持Xcode6,Xcode6没有ReplayKit这个库)
连接iPhone或者iPad之后可以编译并运行这个工程,在真机上运行后可以看到如下界面。
参见附件图片
点击 开始按钮 后就会调用开始录屏的接口,但这个时候不是马上进行录屏,ReplayKit需要初始化完成开自动开始录屏,所以Demo加了一个Loading提示&初始化&
初始化完成后 结束 按钮变为可以点击的状态,并提示 &正在录制&
等要结束时点击 结束按钮,会调用ReplayKit的停止接口,停止接口给了回调后可以显示录屏视频的预览页面,至于要不要显示和如何显示,由各个游戏的前端确定,Demo只是给了个参考的例子。
在视频预览页面可以选择保存到系统相册或者分享到社交网络,还可以拷贝到剪切板,这些操作都可以在回调中获取到,游戏前端可以根据这些回调的信息给用户提示(比如&视频成功保存到系统相册&)
&& 系统默认的分享暂时是看到Facebook Youtube这些,并没有看到有微信微博分享。不过这些视频保存到系统相册之后可以上传到优酷,后续生成链接并分享出去的还没有测试过。
Demo中的时间和进度条只是模拟了游戏中的动画,不然只有静止画面,看不出视频的效果。
其他:Demo中的函数都附带了注释说明,可以自由修改并自由分发。
ReplayKit的官网使用说明&;
Demo代码:
1 #import "ViewController.h"
2 #import &ReplayKit/ReplayKit.h&
4 static NSString *StartRecord = @"开始";
5 static NSString *StopRecord = @"结束";
7 #if TARGET_IPHONE_SIMULATOR
8 #define SIMULATOR 1
9 #elif TARGET_OS_IPHONE
10 #define SIMULATOR 0
13 #define AnimationDuration (0.3)
16 @interface ViewController () &RPPreviewViewControllerDelegate&
20 @property (nonatomic, strong)UIButton *btnS
21 @property (nonatomic, strong)UIButton *btnS
22 @property (nonatomic, strong)NSTimer *progressT
23 @property (nonatomic, strong)UIProgressView *progressV
24 @property (nonatomic, strong)UIActivityIndicatorView *
25 @property (nonatomic, strong)UIView *tipV
26 @property (nonatomic, strong)UILabel *lbT
27 @property (nonatomic, strong)UILabel *lbT
31 @implementation ViewController
33 - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
39 - (void)viewDidAppear:(BOOL)animated {
BOOL isVersionOk = [self isSystemVersionOk];
if (!isVersionOk) {
NSLog(@"系统版本需要是iOS9.0及以上才支持ReplayKit");
if (SIMULATOR) {
[self showSimulatorWarning];
UILabel *lb =
CGSize screenSize = [UIScreen mainScreen].bounds.
lb = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 140)];
lb.font = [UIFont boldSystemFontOfSize:32];
lb.backgroundColor = [UIColor clearColor];
lb.textColor = [UIColor blackColor];
lb.textAlignment = NSTextAlignmentC
lb.numberOfLines = 3;
lb.text = @"苹果ReplayKit Demo";
lb.center =
CGPointMake(screenSize.width/2, 80);
[self.view addSubview:lb];
//创建按钮
UIButton *btn = [self createButtonWithTitle:StartRecord andCenter:CGPointMake(screenSize.width/2 - 100, 200)];
[self.view addSubview:btn];
self.btnStart =
btn = [self createButtonWithTitle:StopRecord andCenter:CGPointMake(screenSize.width/2 + 100, 200)];
[self.view addSubview:btn];
self.btnStop =
[self setButton:btn enabled:NO];
//loading指示
UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 80)];
[self.view addSubview:view];
view.backgroundColor = [UIColor redColor];
view.layer.cornerRadius = 8.0f;
view.center = CGPointMake(screenSize.width/2, 300);
activity.center = CGPointMake(30, view.frame.size.height/2);
[view addSubview:activity];
[activity startAnimating];
self.activity =
lb = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 280, 80)];
lb.font = [UIFont boldSystemFontOfSize:20];
lb.backgroundColor = [UIColor clearColor];
lb.textColor = [UIColor blackColor];
lb.layer.cornerRadius = 4.0;
lb.textAlignment = NSTextAlignmentC
[view addSubview:lb];
self.lbTip =
self.tipView =
[self hideTip];
//显示时间(用于看录制结果时能知道时间)
lb = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];
lb.font = [UIFont boldSystemFontOfSize:20];
lb.backgroundColor = [UIColor redColor];
lb.textColor = [UIColor blackColor];
lb.layer.cornerRadius = 4.0;
NSDateFormatter * dateFormat = [[NSDateFormatter alloc] init] ;
[dateFormat setDateFormat: @"HH:mm:ss"];
NSString *dateString = [dateFormat stringFromDate:[NSDate date]];
lb.center = CGPointMake(screenSize.width/2, screenSize.height/2 + 100);
lb.textAlignment = NSTextAlignmentC
[self.view addSubview:lb];
self.lbTime =
//进度条 (显示动画,不然看不出画面的变化)
UIProgressView *progress = [[UIProgressView alloc] initWithFrame:CGRectMake(0, 0, screenSize.width*0.8, 10)];
progress.center = CGPointMake(screenSize.width/2, screenSize.height/2 + 150);
progress.progressViewStyle = UIProgressViewStyleD
progress.progress = 0.0;
[self.view addSubview:progress];
self.progressView =
//更新时间
[NSTimer scheduledTimerWithTimeInterval:1.0f
target:self
selector:@selector(updateTimeString)
userInfo:nil
repeats:YES];
131 #pragma mark - UI控件
132 //显示 提示信息
133 - (void)showTipWithText:(NSString *)tip activity:(BOOL)activity{
[self.activity startAnimating];
self.lbTip.text =
self.tipView.hidden = NO;
if (activity) {
self.activity.hidden = NO;
[self.activity startAnimating];
[self.activity stopAnimating];
self.activity.hidden = YES;
145 //隐藏 提示信息
146 - (void)hideTip {
self.tipView.hidden = YES;
[self.activity stopAnimating];
151 //创建按钮
152 - (UIButton *)createButtonWithTitle:(NSString *)title andCenter:(CGPoint)center {
CGRect rect = CGRectMake(0, 0, 160, 60);
UIButton *btn = [[UIButton alloc] initWithFrame:rect];
btn.layer.cornerRadius = 5.0;
btn.layer.borderWidth = 2.0;
btn.layer.borderColor = [[UIColor blackColor] CGColor];
btn.backgroundColor = [UIColor lightGrayColor];
btn.center =
[btn setTitle:title forState:UIControlStateNormal];
[btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[btn addTarget:self action:@selector(onBtnPressed:) forControlEvents:UIControlEventTouchDown];
168 //设置按钮是否可点击
169 - (void)setButton:(UIButton *)button enabled:(BOOL)enabled {
if (enabled) {
button.alpha = 1.0;
button.alpha = 0.2;
button.enabled =
178 //提示不支持模拟器
179 - (void)showSimulatorWarning {
UIAlertAction *actionOK = [UIAlertAction actionWithTitle:@"好的" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action){
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"ReplayKit不支持模拟器" message:@"请使用真机运行这个Demo工程" preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:actionCancel];
[alert addAction:actionOK];
[self presentViewController:alert animated:NO completion:nil];
193 //显示弹框提示
194 - (void)showAlert:(NSString *)title andMessage:(NSString *)message {
if (!title) {
title = @"";
if (!message) {
message = @"";
UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:@"好的" style:UIAlertActionStyleCancel handler:nil];
UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:actionCancel];
[self presentViewController:alert animated:NO completion:nil];
207 //显示视频预览页面,animation=是否要动画显示
208 - (void)showVideoPreviewController:(RPPreviewViewController *)previewController withAnimation:(BOOL)animation {
__weak ViewController *weakSelf =
//UI需要放到主线程
dispatch_async(dispatch_get_main_queue(), ^{
CGRect rect = [UIScreen mainScreen].
if (animation) {
rect.origin.x += rect.size.
previewController.view.frame =
rect.origin.x -= rect.size.
[UIView animateWithDuration:AnimationDuration animations:^(){
previewController.view.frame =
} completion:^(BOOL finished){
previewController.view.frame =
[weakSelf.view addSubview:previewController.view];
[weakSelf addChildViewController:previewController];
240 //关闭视频预览页面,animation=是否要动画显示
241 - (void)hideVideoPreviewController:(RPPreviewViewController *)previewController withAnimation:(BOOL)animation {
//UI需要放到主线程
dispatch_async(dispatch_get_main_queue(), ^{
CGRect rect = previewController.view.
if (animation) {
rect.origin.x += rect.size.
[UIView animateWithDuration:AnimationDuration animations:^(){
previewController.view.frame =
} completion:^(BOOL finished){
//移除页面
[previewController.view removeFromSuperview];
[previewController removeFromParentViewController];
//移除页面
[previewController.view removeFromSuperview];
[previewController removeFromParentViewController];
267 #pragma mark - 按钮 回调
268 //按钮事件
269 - (void)onBtnPressed:(UIButton *)sender {
//点击效果
sender.transform = CGAffineTransformMakeScale(0.8, 0.8);
float duration = 0.3;
[UIView animateWithDuration:duration
animations:^{
sender.transform = CGAffineTransformMakeScale(1.1, 1.1);
}completion:^(BOOL finish){
[UIView animateWithDuration:duration
animations:^{
sender.transform = CGAffineTransformMakeScale(1.0, 1.0);
}completion:^(BOOL finish){ }];
NSString *function = sender.titleLabel.
if ([function isEqualToString:StartRecord]) {
[self startRecord];
else if ([function isEqualToString:StopRecord]) {
[self stopRecord];
294 - (void)startRecord {
[self setButton:self.btnStart enabled:NO];
NSLog(@"ReplayKit只支持真机录屏,支持游戏录屏,不支持录avplayer播放的视频");
NSLog(@"检查机器和版本是否支持ReplayKit录制...");
if ([[RPScreenRecorder sharedRecorder] isAvailable]) {
NSLog(@"支持ReplayKit录制");
NSLog(@"!!不支持支持ReplayKit录制!!");
__weak ViewController *weakSelf =
NSLog(@"%@ 录制", StartRecord);
[self showTipWithText:@"录制初始化" activity:YES];
//在此可以设置是否允许麦克风(传YES即是使用麦克风,传NO则不是用麦克风)
[[RPScreenRecorder sharedRecorder] startRecordingWithMicrophoneEnabled:NO handler:^(NSError *error){
NSLog(@"录制开始...");
[weakSelf hideTip];
if (error) {
NSLog(@"错误信息 %@", error);
[weakSelf showTipWithText:error.description activity:NO];
//其他处理
[weakSelf setButton:self.btnStop enabled:YES];
[weakSelf setButton:self.btnStart enabled:NO];
[weakSelf showTipWithText:@"正在录制" activity:NO];
//更新进度条
weakSelf.progressTimer = [NSTimer scheduledTimerWithTimeInterval:0.05f
target:self
selector:@selector(changeProgressValue)
userInfo:nil
repeats:YES];
335 - (void)stopRecord {
NSLog(@"%@ 录制", StopRecord);
[self setButton:self.btnStart enabled:YES];
[self setButton:self.btnStop enabled:NO];
__weak ViewController *weakSelf =
[[RPScreenRecorder sharedRecorder] stopRecordingWithHandler:^(RPPreviewViewController *previewViewController, NSError *
if (error) {
NSLog(@"失败消息:%@", error);
[weakSelf showTipWithText:error.description activity:NO];
[weakSelf showTipWithText:@"录制完成" activity:NO];
//显示录制到的视频的预览页
NSLog(@"显示预览页面");
previewViewController.previewControllerDelegate = weakS
//去除计时器
[weakSelf.progressTimer invalidate];
weakSelf.progressTimer =
[self showVideoPreviewController:previewViewController withAnimation:YES];
365 #pragma mark - 视频预览页面 回调
366 //关闭的回调
367 - (void)previewControllerDidFinish:(RPPreviewViewController *)previewController {
[self hideVideoPreviewController:previewController withAnimation:YES];
371 //选择了某些功能的回调(如分享和保存)
372 - (void)previewController:(RPPreviewViewController *)previewController didFinishWithActivityTypes:(NSSet &NSString *& *)activityTypes {
__weak ViewController *weakSelf =
if ([activityTypes containsObject:@"com.apple.UIKit.activity.SaveToCameraRoll"]) {
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf showAlert:@"保存成功" andMessage:@"已经保存到系统相册"];
if ([activityTypes containsObject:@"com.apple.UIKit.activity.CopyToPasteboard"]) {
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf showAlert:@"复制成功" andMessage:@"已经复制到粘贴板"];
388 #pragma mark - 计时器 回调
390 //改变进度条的显示的进度
391 - (void)changeProgressValue {
float progress = self.progressView.progress + 0.01;
[self.progressView setProgress:progress animated:NO];
if (progress &= 1.0) {
self.progressView.progress = 0.0;
398 //更新显示的时间
399 - (void)updateTimeString {
NSDateFormatter * dateFormat = [[NSDateFormatter alloc] init] ;
[dateFormat setDateFormat: @"HH:mm:ss"];
NSString *dateString = [dateFormat stringFromDate:[NSDate date]];
self.lbTime.text =
406 #pragma mark - 其他
407 - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
412 //判断对应系统版本是否支持ReplayKit
413 - (BOOL)isSystemVersionOk {
if ([[UIDevice currentDevice].systemVersion floatValue] & 9.0) {
return NO;
return YES;
阅读(...) 评论()DJ Snake视频搬运工~
喜欢蛇的旁友关注我的微博 @我是兴趣使然的绅士投稿:45粉丝:391分享--dynmicweibozoneqqbaidu将视频贴到博客或论坛视频地址复制嵌入代码复制微信扫一扫分享收藏0硬币--稍后看马克一下~用手机看转移阵地~用或其他应用扫描二维码手机下视频请使用扫码若未安装客户端,可直接扫此码下载应用看过该视频的还喜欢正在加载...miniOFFInstagram的直播live视频如何下载? - 知乎有问题,上知乎。知乎作为中文互联网最大的知识分享平台,以「知识连接一切」为愿景,致力于构建一个人人都可以便捷接入的知识分享网络,让人们便捷地与世界分享知识、经验和见解,发现更大的世界。3被浏览405分享邀请回答0添加评论分享收藏感谢收起一款让所有人都满意的免费屏幕录像软件
手机扫描下载
拍照摄影排行榜
AZ Screen Recorder可以说是录屏界的大咖了,很多地方都可以看到它的推荐。首先是操作起来非常的舒服,简约的浮动操作面板,开启录屏时隐藏,其次就是视频配置,可以根据需求调整,输出高清视频无压力,还能直接生成gif,但这通常需要较长处理时间,加上5.0系统开放了api后无需root就能录屏后应用更加广泛了在谷歌商店 首页,CNET,雅虎新闻,Android Central以及其他网站都是推荐产品
它是您的最佳安卓屏幕录 像软件。 它不需要root权限,无录制时长限制,录像操作简便并且可以一键开始和停止,无水印,无广告。
AZ Screen Recorder 可以录制全高清(FullHD)和四分之一全高清(QHD)视频,而且 它是安卓市场中唯一一款可在录制过程中暂停和恢复录制的产品。 此外,您还可以用设备的麦克 风录制同步音频,在录像视频中显示屏幕触点,选择录像分辨率,帧率及比特率,设置开始倒计 时,显示文字和Logo,保存视频到SD卡,设置延时和慢镜头等。 所有这些功能都是免费的!
我们 的目标是开发一款让所有人都满意的免费屏幕录像软件,当然如果您愿意支持我们或者想升级功 能,您可以购买付费版。 付费版功能包括: 增加可隐藏的控制按钮,前置摄像头,gif转换器,视 频剪切,视频图画等等。
现在有很多主播都转战手机游戏,开始在手机上直播了,想要在直播手机游戏,就必须有录屏软件来配合,今天小编就为各位主播推荐一些好用的录屏软件,各位主播快来下载吧!
2018 / 06 / 28
2018 / 06 / 28
2018 / 06 / 28
2018 / 06 / 28
2018 / 06 / 28
2018 / 06 / 28
2018 / 06 / 28
腾讯WiFi管家
广告净化神器
避雷抢红包
360手机助手
手机客户端
微信公众号
人已预约此应用
关注"安软市场"微信公众号
玩最新好玩的手机游戏Sina Visitor System

我要回帖

更多关于 苹果录屏大师怎么直播 的文章

 

随机推荐