大多数做直播的时候使用 FFMpeg.  IJKMediaFramework也是基于FFMpeg封装 使用起来比较简单,个人觉得如果有能力可以使用 FFMpeg , 使用 FFMpeg对 内存的占用比IJKMediaFramework少

关于IJKMediaFramework 集成 可以关注网上别人写的 githubhttp://blog.csdn.net/github_33362155/article/details/51801499

//
// PlayerViewController.m
// LittleLoveLive
//
// Created by Apple on 16/7/20.
// Copyright © 2016年 YJ. All rights reserved.
// #import "PlayerViewController.h"
#import <IJKMediaFramework/IJKMediaFramework.h>
#import <Accelerate/Accelerate.h> @interface PlayerViewController () @property (atomic, strong) NSURL *url;
@property (atomic, retain) id <IJKMediaPlayback> player;
@property (weak, nonatomic) UIView *PlayerView;
@property (nonatomic, strong)UIImageView *dimIamge; @end @implementation PlayerViewController -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:YES]; [self.navigationController setNavigationBarHidden:YES animated:YES]; if (![self.player isPlaying]) {
[self.player prepareToPlay];
}
} - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:YES];
[self.navigationController setNavigationBarHidden:NO animated:NO];
} - (void)viewDidLoad {
[super viewDidLoad]; self.view.backgroundColor = [UIColor blackColor]; self.url = [NSURL URLWithString:@"http://live.hkstv.hk.lxdns.com/live/hks/playlist.m3u8"];
_player = [[IJKFFMoviePlayerController alloc] initWithContentURL:self.url withOptions:nil];
UIView *playerView = [self.player view];
UIView *displayView = [[UIView alloc] initWithFrame:self.view.bounds];
self.PlayerView = displayView;
self.PlayerView.backgroundColor = [UIColor blackColor];
[self.view addSubview:self.PlayerView]; playerView.frame = self.PlayerView.bounds;
playerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.PlayerView insertSubview:playerView atIndex:];
[_player setScalingMode:IJKMPMovieScalingModeAspectFill];
[self installMovieNotificationObservers]; [self loadingView];
[self changeBackBtn]; } //关闭
- (void)goBackBtnClick { //停止播放
[self.player pause]; [self.navigationController popViewControllerAnimated:YES];
} #pragma Selector func - (void)loadStateDidChange:(NSNotification*)notification {
IJKMPMovieLoadState loadState = _player.loadState; if ((loadState & IJKMPMovieLoadStatePlaythroughOK) != ) {
NSLog(@"LoadStateDidChange: IJKMovieLoadStatePlayThroughOK: %d\n",(int)loadState);
}else if ((loadState & IJKMPMovieLoadStateStalled) != ) {
NSLog(@"loadStateDidChange: IJKMPMovieLoadStateStalled: %d\n", (int)loadState);
} else {
NSLog(@"loadStateDidChange: ???: %d\n", (int)loadState);
}
} - (void)moviePlayBackFinish:(NSNotification*)notification {
int 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(@"mediaIsPrepareToPlayDidChange\n");
} - (void)moviePlayBackStateDidChange:(NSNotification*)notification { _dimIamge.hidden = YES; switch (_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;
}
}
} #pragma Install Notifiacation - (void)installMovieNotificationObservers { [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(loadStateDidChange:)
name:IJKMPMoviePlayerLoadStateDidChangeNotification
object:_player];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackFinish:)
name:IJKMPMoviePlayerPlaybackDidFinishNotification
object:_player]; [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(mediaIsPreparedToPlayDidChange:)
name:IJKMPMediaPlaybackIsPreparedToPlayDidChangeNotification
object:_player]; [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackStateDidChange:)
name:IJKMPMoviePlayerPlaybackStateDidChangeNotification
object:_player]; } - (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]; } // 按钮
- (void)changeBackBtn
{
// 返回
UIButton * backBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
backBtn.frame = CGRectMake(kScreenWidth-50.0f, 10.0f, 40.0f, 40.0f);
[backBtn setImage:[UIImage imageNamed:@"close_btn_show_view.png"] forState:(UIControlStateNormal)];
[backBtn addTarget:self action:@selector(goBackBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
backBtn.layer.shadowColor = [UIColor blackColor].CGColor;
backBtn.layer.shadowOffset = CGSizeMake(, );
backBtn.layer.shadowOpacity = 0.5;
backBtn.layer.shadowRadius = ;
[self.view addSubview:backBtn];
} //加载拉丝模糊视图
- (void)loadingView { self.dimIamge = [[UIImageView alloc] initWithFrame:self.view.bounds];
[self.dimIamge sd_setImageWithURL:[NSURL URLWithString:self.urlStr] placeholderImage:IMAGENAMED(@"bg_loading.png") options:SDWebImageCacheMemoryOnly];
UIVisualEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
visualEffectView.frame = _dimIamge.bounds;
[_dimIamge addSubview:visualEffectView];
[self.view addSubview:_dimIamge]; } - (void)dealloc { [self.player shutdown];
[[NSNotificationCenter defaultCenter] removeObserver:self];
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; } @end

IJKMediaFramework第三方库的使用的更多相关文章

  1. ios常用的第三方库

    ios开发中有可能用到的第三方库进行记录一下: 注:资料信息来源于网络 自己整理  https://developer.apple.com/reference(苹果官方文档) https://gith ...

  2. Egret 集成第三方库 记录

    引入第三方库pureMVC 这次我们要使用到一个mvc开发框架-pureMVC,熟悉as3的朋友一定也对这个框架不陌生吧.不熟悉的也没关系,这个框架不是这次的主角.我们从 这里 下载pureMVC的T ...

  3. iOS:实现图片的无限轮播(二)---之使用第三方库SDCycleScrollView

    iOS:实现图片的无限轮播(二)---之使用第三方库SDCycleScrollView 时间:2016-01-19 19:13:43      阅读:630      评论:0      收藏:0   ...

  4. Qt-导入第三方库

    Qt提供了显式和隐式导入第三方库方法,本文只介绍显示导入方法. 第三方提供的库文件包括ControlCAN.h,ControlCAN.dll和ControlCAN.lib.将ControlCAN.h和 ...

  5. Facebook Paper使用的第三方库

    Facebook Paper使用的第三方库 第三方库名 简介 链接 ACE code editor https://github.com/ajaxorg/ace Appirater 用户评分组件 ht ...

  6. iOS开发之第三方库的学习--hpple的使用

    前言:因为在开发中很可能会遇到html解析,如果后台提供的数据只有html数据,或者开发的app需要从web前端的html里获取数据,就需要html解析工具了. 关于HTML解析库,可以阅读:收集几个 ...

  7. iOS真机调试引入第三方库(如友盟等)编译时候,出现错误提示

    用Xcode 7 beta 3在真机(iOS 8.3)上运行一下工程,结果发现工程编译不过.看了下问题,报的是以下错误: MARK:解决方法:在building Setting 中设置bitCode ...

  8. Pycharm如何添加第三方库和插件

    首先打开Pycharm,点击左上角  >>File  >>Setting . 打开之后点击 >>PRoject :untitled   >>Projec ...

  9. import第三方库的头文件找不到的错误

    问题描述:使用cocoapods导入了第三方库,import该第三方库的某个头文件,然后编译报错找不到这个头文件内所import的头文件. 产生原因:我们需要配置头文件的搜索路径,告诉系统头文件的路径 ...

随机推荐

  1. ERROR (ClientException): Unexpected API Error

  2. linux高级数据存储

    linux内此存储模式由5部分组成,自低向上的顺序: 物理卷,内核块设备驱动,内核文件系统驱动,虚拟文件系统,应用程序数据结构; 系统中所有的文件仅按此模式存储,无论是数据还是元数据,均在此模式下统一 ...

  3. 第二百四十二天 how can I 坚持

    今天... 貌似没啥啊. 第一天带帽子上班. 还有回来买了两个柚子吃了,有点上火啊. 还有今天雾霾爆表啊,pm2.5  600多啊. 还有看了部电影<蚁人>,挺好看.希望不会出二.三.四. ...

  4. homework-02 最大子区域和

    题目描述 题目建立上一个作业的题目基础上,上一次作业是要求在一个一维序列里找一个最大连续子串,这次task最基础的要求是在一个二维表里找一个最大连续子矩形,但是这次作业有若干个升级版,分别要求可以加入 ...

  5. JDBC学习笔记(9)——DBUtils的使用

    使用DBUtils提供的功能需要使用commons-dbutils-1.6.jar这个JAR包,在Apache官网可以下载到 使用DBUtils进行更新操 测试QueryRunner类的update方 ...

  6. HDU 5792 World is Exploding (树状数组)

    World is Exploding 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5792 Description Given a sequence ...

  7. linux性能问题(CPU,内存,磁盘I/O,网络)

    一. CPU性能评估 1.vmstat [-V] [-n] [depay [count]] -V : 打印出版本信息,可选参数 -n : 在周期性循环输出时,头部信息仅显示一次 delay : 两次输 ...

  8. UVaLive 6855 Banks (水题,暴力)

    题意:给定 n 个数,让你求最少经过几次操作,把所有的数变成非负数,操作只有一种,变一个负数变成相反数,但是要把左右两边的数加上这个数. 析:由于看他们AC了,时间这么短,就暴力了一下,就AC了... ...

  9. 图文讲解:iOS App提交流程

    原文:http://www.toceansoft.com/ios/3287.jhtml 一.证书的导出 1.1.前期工作 首先你需要有一个苹果的开发者帐号,一个Mac系统. 如果没有帐号可以在打开ht ...

  10. poj3041

    Asteroids Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12162   Accepted: 6620 Descri ...