直播推流之blibli和拉流LFLiveKit
执行上面操作后,导入合成的拉流blibli包到工程中,然后新建个播放控制器来设置播放
1. 播放的一些操作。
2. 高斯模糊。
3. 新建聊天控制器。
-(void)viewDidLoad {[super viewDidLoad];// Do any additional setup after loading the view from its nib.[self initPlayer];//添加播放器[self loadUI]; //添加高斯模糊[self loadChatVC]; //加载聊天控制器
}
- (void)viewWillAppear:(BOOL)animated {[super viewWillAppear:animated];self.navigationController.navigationBar.hidden = YES;[self installMovieNotificationObservers];[self.player prepareToPlay];
}- (void)viewDidDisappear:(BOOL)animated {[super viewDidDisappear:animated];self.navigationController.navigationBar.hidden = NO;[self.player shutdown];[self removeMovieNotificationObservers];
}
- (void)setLives:(STRHotLive *)lives{_lives = lives;
}
- (void)initPlayer{
#ifdef DEBUG[IJKFFMoviePlayerController setLogReport:YES];[IJKFFMoviePlayerController setLogLevel:k_IJK_LOG_DEBUG];
#else[IJKFFMoviePlayerController setLogReport:NO];[IJKFFMoviePlayerController setLogLevel:k_IJK_LOG_INFO];
#endifIJKFFOptions *options = [IJKFFOptions optionsByDefault];self.player = [[IJKFFMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",_lives.streamAddr]] withOptions:options];self.player.view.frame = self.view.bounds;self.player.scalingMode = IJKMPMovieScalingModeAspectFit;self.player.shouldAutoplay = YES;[self.view addSubview:self.player.view];
}
- (void)loadUI{[self.view setBackgroundColor:STRCOLOR(0, 0, 0)];[self loadBlurImage];
}
- (void)loadChatVC{[self addChildViewController:self.chatVc];[self.view addSubview:self.chatVc.view];self.chatVc.delegate = self;WEAKSELF;[self.chatVc.view mas_makeConstraints:^(MASConstraintMaker *make) {make.edges.equalTo(weakSelf.view);}];
}
- (void)loadBlurImage{UIImageView *blurImageV = [[UIImageView alloc] init];blurImageV.frame = self.view.bounds;[blurImageV sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",_lives.creator.portrait]] placeholderImage:[UIImage imageNamed:@"default_room"]];UIBlurEffect *blurE = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:blurE];effectView.frame = blurImageV.bounds;[blurImageV addSubview:effectView];[self.view addSubview:blurImageV];self.blurImageView = blurImageV;
}
#pragma mark --- delegate
- (void)chatLiveViewController:(STRChatLiveViewController *)chatVc didButtonClickWithSender:(UIButton *)sender{[self dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark --- noti
- (void)loadStateDidChange:(NSNotification*)notification
{// MPMovieLoadStateUnknown = 0,// MPMovieLoadStatePlayable = 1 << 0,// MPMovieLoadStatePlaythroughOK = 1 << 1, // Playback will be automatically started in this state when shouldAutoplay is YES// MPMovieLoadStateStalled = 1 << 2, // Playback will be automatically paused in this state, if startedIJKMPMovieLoadState loadState = _player.loadState;if ((loadState & IJKMPMovieLoadStatePlaythroughOK) != 0) {NSLog(@"loadStateDidChange: IJKMPMovieLoadStatePlaythroughOK: %d\n", (int)loadState);} else if ((loadState & IJKMPMovieLoadStateStalled) != 0) {NSLog(@"loadStateDidChange: IJKMPMovieLoadStateStalled: %d\n", (int)loadState);} else {NSLog(@"loadStateDidChange: ???: %d\n", (int)loadState);}
}- (void)moviePlayBackDidFinish:(NSNotification*)notification
{// MPMovieFinishReasonPlaybackEnded,// MPMovieFinishReasonPlaybackError,// MPMovieFinishReasonUserExitedint reason = [[[notification userInfo] valueForKey:IJKMPMoviePlayerPlaybackDidFinishReasonUserInfoKey] intValue];switch (reason){case IJKMPMovieFinishReasonPlaybackEnded:NSLog(@"playbackStateDidChange: IJKMPMovieFinishReasonPlaybackEnded: %d\n", reason);break;case IJKMPMovieFinishReasonUserExited:NSLog(@"playbackStateDidChange: IJKMPMovieFinishReasonUserExited: %d\n", reason);break;case IJKMPMovieFinishReasonPlaybackError:NSLog(@"playbackStateDidChange: IJKMPMovieFinishReasonPlaybackError: %d\n", reason);break;default:NSLog(@"playbackPlayBackDidFinish: ???: %d\n", reason);break;}
}- (void)mediaIsPreparedToPlayDidChange:(NSNotification*)notification
{NSLog(@"mediaIsPreparedToPlayDidChange\n");
}- (void)moviePlayBackStateDidChange:(NSNotification*)notification
{// MPMoviePlaybackStateStopped,// MPMoviePlaybackStatePlaying,// MPMoviePlaybackStatePaused,// MPMoviePlaybackStateInterrupted,// MPMoviePlaybackStateSeekingForward,// MPMoviePlaybackStateSeekingBackwardswitch (_player.playbackState){case IJKMPMoviePlaybackStateStopped: {NSLog(@"IJKMPMoviePlayBackStateDidChange %d: stoped", (int)_player.playbackState);break;}case IJKMPMoviePlaybackStatePlaying: {NSLog(@"IJKMPMoviePlayBackStateDidChange %d: playing", (int)_player.playbackState);break;}case IJKMPMoviePlaybackStatePaused: {NSLog(@"IJKMPMoviePlayBackStateDidChange %d: paused", (int)_player.playbackState);break;}case IJKMPMoviePlaybackStateInterrupted: {NSLog(@"IJKMPMoviePlayBackStateDidChange %d: interrupted", (int)_player.playbackState);break;}case IJKMPMoviePlaybackStateSeekingForward:case IJKMPMoviePlaybackStateSeekingBackward: {NSLog(@"IJKMPMoviePlayBackStateDidChange %d: seeking", (int)_player.playbackState);break;}default: {NSLog(@"IJKMPMoviePlayBackStateDidChange %d: unknown", (int)_player.playbackState);break;}}self.blurImageView.hidden = YES;[self.blurImageView removeFromSuperview];
}#pragma mark Install Movie Notifications/* Register observers for the various movie object notifications. */
-(void)installMovieNotificationObservers
{[[NSNotificationCenter defaultCenter] addObserver:selfselector:@selector(loadStateDidChange:)name:IJKMPMoviePlayerLoadStateDidChangeNotificationobject:_player];[[NSNotificationCenter defaultCenter] addObserver:selfselector:@selector(moviePlayBackDidFinish:)name:IJKMPMoviePlayerPlaybackDidFinishNotificationobject:_player];[[NSNotificationCenter defaultCenter] addObserver:selfselector:@selector(mediaIsPreparedToPlayDidChange:)name:IJKMPMediaPlaybackIsPreparedToPlayDidChangeNotificationobject:_player];[[NSNotificationCenter defaultCenter] addObserver:selfselector:@selector(moviePlayBackStateDidChange:)name:IJKMPMoviePlayerPlaybackStateDidChangeNotificationobject:_player];
}#pragma mark Remove Movie Notification Handlers/* Remove the movie notification observers from the movie object. */
-(void)removeMovieNotificationObservers
{[[NSNotificationCenter defaultCenter]removeObserver:self name:IJKMPMoviePlayerLoadStateDidChangeNotification object:_player];[[NSNotificationCenter defaultCenter]removeObserver:self name:IJKMPMoviePlayerPlaybackDidFinishNotification object:_player];[[NSNotificationCenter defaultCenter]removeObserver:self name:IJKMPMediaPlaybackIsPreparedToPlayDidChangeNotification object:_player];[[NSNotificationCenter defaultCenter]removeObserver:self name:IJKMPMoviePlayerPlaybackStateDidChangeNotification object:_player];
}
#pragma mark --- getters and setters
- (STRChatLiveViewController *)chatVc{if (_chatVc == nil) {_chatVc = [[STRChatLiveViewController alloc] init];}return _chatVc;
}
转载于:https://www.cnblogs.com/TheYouth/p/6257229.html
直播推流之blibli和拉流LFLiveKit相关推荐
- rtsp推流桌面,vlc拉流
rtsp推流桌面,vlc拉流 首先去vlc下载官网:https://www.videolan.org/ 下载vlc播放器. 1.vlc下载完成之后打开vlc,点击媒体->流 2.在捕获模式选择' ...
- iOS开发之iOS15.6之后拉流LFLiveKit,画面模糊及16.1马赛克问题
更新了iOS15.6系统后,发现拉取LFLiveKit进行直播的流,竟然是这样的: 模糊不清,于是思考是什么原因导致的. 1.是不是拉流端出现的问题? 使用安卓拉取iOS的直播流,是同样的效果,又考虑 ...
- ffmpeg推流+NGINX(RTMP)+VLC-QT拉流(Win7)
1 简介 本文旨在在Windows 7系统上实现利用FFmpeg软件推流到部署的带RTMP模块的Nginx流媒体服务器上,在拉流端,基于VLC库的VLC-QT库实现拉流播放. 2 ffmpeg下载安装 ...
- SRS 4.0流媒体服务器开发环境搭建:包括推流、服务器配置、拉流测试
SRS 4.0流媒体服务器入门系列 结合SRS官方Wiki以及本人对SRS的理解,推出<SRS 4.0流媒体服务器入门系列>,包括内容: SRS 4.0 开发环境搭建 SRS 4.0 配置 ...
- Java使用FFmpeg进行推流,SRS进行拉流,实现转码
因为公司业务需要把监控摄像机的RTSP流放在浏览器上播放,但由于目前浏览器上播放RTSP协议的视频流需要集成插件,插件只能在固定的浏览器版本上使用,缺点比较大,所以想着通过转码的方式实现在浏览器上播 ...
- SRS4 对接海康威视GB28181协议推流 RTMP、webRTC拉流
一.系统环境 Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-88-generic x86_64) 三.源代码.配置.编译.运行 git clone https://githu ...
- 推流和拉流的概念以及RTMP和HLS协议
https://www.bbsmax.com/A/x9J2wZM56o/ 推流为将直播内容推送至服务器的过程:拉流为服务器已有直播内容,用指定地址进行拉取的过程. rtmp rtmp是Real Tim ...
- 直播推流 ffmpeg 拉流二次转发 记录
因 前两天老大给我发了个任务,说让我做一个flask 服务器接口,接收请求,在请求参数中获取 直播拉流地址和 推流地址,然后调用 ffmpeg 到拉流地址上进行拉流 将拉到的流媒体数据推到另一个直播服 ...
- 直播平台源码中的推拉流是什么
关于直播平台源码中的推流和拉流,最常用的就是RTMP和RTSP协议了 推流,指的是把采集阶段封包好的内容传输到服务器的过程,推流是直播端需要完成的步骤.拉流是指服务器已有直播内容,用指定地址进行拉取的 ...
- 关于拉流端ts时间切片问题导致的直播黑屏问题
公司直播使用的是阿里的直播服务,但是华为的部分手机出现了黑屏,无法观看直播 首先搞懂推拉流 推流: 经过obs等推流工具,将要直播的流文件推送到阿里的直播服务器上 拉流: 遍布全国的阿里直播服务器将流 ...
最新文章
- 收藏 | 阿里云Redis开发规范
- 李宏毅机器学习课程11~~~为何要深?
- YbtOJ#652-集合比较【Treap】
- win7插了耳机还是外放_有哪些令人叫绝的智障设计?网友:手机取消耳机孔
- 案例解释图像傅里叶变换的幅度谱和相位谱的以及反变换
- c# npoi 公式不计算_建筑行业计算公式大全,钢筋重量计算公式,不收藏吃亏的是你自己...
- java界面ATM机取款后的余额_java_ATM机银行存取款系统的设计与实现本科毕业论文...
- python之optparse模块
- 二十五、JAVA多线程(三、线程同步)
- 建立项目接口文档_一个 SpringBoot 项目该包含哪些?
- SAP ABAP开发从入门到精通——第15章 面向对象ALV
- 数据库和数据库实例的概念
- 计算主波长色纯度色温和色坐标转换CIE1931图色坐标显示NTSC色饱和度
- MSP430F149与ESP8266串口通信(中)
- html 字体兼容,设置兼容浏览器的中文字体
- Kruskal算法(克鲁斯卡尔)最小生成树
- display和visility
- 嵌入式系统之实时系统调度算法
- html个个代码的意思,网页HTML中各个代码意思大全
- WEB 在线相册小系统
热门文章
- matlab读取i o数据文件,Matlab 的数据文件读取
- C# Socket编程 通过线程方式的异步
- python 使用 ipx协议_肝了三天,万字长文教你玩转 tcpdump,从此抓包不用愁
- 跨多个专业的从业者想转行做单片机怎么办
- Collectors.mapping()
- 外层div自动撑大为什么没有最大_在工业自动化行业,为什么电阻触摸屏更受欢迎...
- 基于数据报套接字的服务器回射程序设计_套接字Socket的常见面试题及答案
- XMLHttpRequest接收JSON请求
- 【渝粤教育】国家开放大学2018年秋季 0008-21T简明现代汉语 参考试题
- 【渝粤教育】电大中专机电设备管理作业 题库