Skip to content

Commit

Permalink
Update to 2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
0dayZh committed Nov 30, 2015
1 parent 893dcd6 commit 5499b21
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 24 deletions.
7 changes: 7 additions & 0 deletions APIDiffs/api-diffs-2.0.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# PLPlayerKit 2.0.1 to 2.0.2 API Differences

## General Headers

```PLPlayer.h```

- *Added* `@property (nonatomic, assign) NSTimeInterval timeoutIntervalForMediaPackets;`
64 changes: 52 additions & 12 deletions Example/PLPlayerKit/PLPlayerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ @interface PLPlayerViewController ()
PLPlayerDelegate
>
@property (nonatomic, strong) PLPlayer *player;
@property (nonatomic, weak) UIActivityIndicatorView *activityIndicatorView;

@end

Expand All @@ -44,34 +45,59 @@ - (void)dealloc {
self.player = nil;
}

- (void)viewDidLoad {
[super viewDidLoad];

PLPlayer *player = [PLPlayer playerWithURL:self.url];
player.delegate = self;
self.player = player;

- (void)startPlayer {
__weak typeof(self) wself = self;
[self.player prepareToPlayWithCompletion:^(NSError *error) {
if (!error) {
__strong typeof(wself) strongSelf = wself;
UIView *playerView = strongSelf.player.playerView;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:strongSelf action:@selector(tap:)];
[playerView addGestureRecognizer:tap];

// [optional] set time out interval in seconds
strongSelf.player.timeoutIntervalForMediaPackets = 8;

// add player view
UIView *playerView = strongSelf.player.playerView;
playerView.contentMode = UIViewContentModeScaleAspectFill;
playerView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth;
[strongSelf.view addSubview:playerView];

if (strongSelf.isViewLoaded && PLPlayerStatusReady == strongSelf.player.status) {
[strongSelf addActivityIndicatorView];
[strongSelf.player play];
}
}
}];
}

- (void)viewDidLoad {
[super viewDidLoad];

PLPlayer *player = [PLPlayer playerWithURL:self.url];
player.delegate = self;
self.player = player;

[self startPlayer];

__weak typeof(self) wself = self;
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidEnterBackgroundNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {
__strong typeof(wself) strongSelf = wself;
if (strongSelf.player.isPlaying) {
[strongSelf.player stop];
if (strongSelf.player.playerView.superview) {
[strongSelf.player.playerView removeFromSuperview];
}
}
}];
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillEnterForegroundNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {
__strong typeof(wself) strongSelf = wself;
[strongSelf startPlayer];
}];
}

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];

if (PLPlayerStatusReady == self.player.status) {
[self addActivityIndicatorView];
[self.player play];
}
}
Expand All @@ -86,17 +112,31 @@ - (void)viewWillDisappear:(BOOL)animated {

#pragma mark -

- (void)tap:(UITapGestureRecognizer *)tap {
self.player.isPlaying ? [self.player pause] : [self.player resume];
- (void)addActivityIndicatorView {
if (self.activityIndicatorView) {
return;
}
UIActivityIndicatorView *activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
activityIndicatorView.center = CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds));
[self.view addSubview:activityIndicatorView];
[activityIndicatorView stopAnimating];

self.activityIndicatorView = activityIndicatorView;
}

#pragma mark - <PLPlayerDelegate>

- (void)player:(nonnull PLPlayer *)player statusDidChange:(PLPlayerStatus)state {
NSLog(@"%@", status[state]);
if (PLPlayerStatusCaching == state) {
[self.activityIndicatorView startAnimating];
} else {
[self.activityIndicatorView stopAnimating];
}
}

- (void)player:(nonnull PLPlayer *)player stoppedWithError:(nullable NSError *)error {
[self.activityIndicatorView stopAnimating];
NSLog(@"%@", error);
}

Expand Down
8 changes: 4 additions & 4 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PODS:
- PLPlayerKit (2.0.0):
- PLPlayerKit/precompiled (= 2.0.0)
- PLPlayerKit/precompiled (2.0.0)
- PLPlayerKit (2.0.2):
- PLPlayerKit/precompiled (= 2.0.2)
- PLPlayerKit/precompiled (2.0.2)

DEPENDENCIES:
- PLPlayerKit (from `../`)
Expand All @@ -11,6 +11,6 @@ EXTERNAL SOURCES:
:path: ../

SPEC CHECKSUMS:
PLPlayerKit: e21b5ac86604c27e78b8325e1e65b7ad730ceb32
PLPlayerKit: 528aac85b6dee310fa6abf430ada52eae63cc685

COCOAPODS: 0.39.0
4 changes: 2 additions & 2 deletions Example/Pods/Local Podspecs/PLPlayerKit.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion PLPlayerKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

Pod::Spec.new do |s|
s.name = "PLPlayerKit"
s.version = "2.0.1"
s.version = "2.0.2"
s.summary = "Pili iOS video player SDK, RTMP, HLS video streaming supported."
s.homepage = "https://github.com/pili-engineering/PLPlayerKit"
s.license = 'Apache License, Version 2.0'
Expand Down
5 changes: 4 additions & 1 deletion Pod/Library/include/PLPlayerKit/PLPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ typedef NS_ENUM(NSInteger, PLPlayerStatus) {

@property (nonatomic, strong, nonnull) NSURL *url;
@property (nonatomic, assign, nullable) id<PLPlayerDelegate> delegate;
/// 接收/发送数据包超时时间间隔, 默认为 10s.
/// 注意: 当前, 该属性在 - (void)prepareToPlayWithCompletion: 的 completion block 中执行才会有效
@property (nonatomic, assign) NSTimeInterval timeoutIntervalForMediaPackets;

@property (nonatomic, strong, nullable) NSError *error;
@property (nonatomic, assign) PLPlayerStatus status;
@property (nonatomic, assign, getter=isPlaying) BOOL playing;

// render
/// 注意playerView 必须在调用完 - (void)prepareToPlayWithCompletion: 后才能访问到正常的值
/// 注意: playerView 必须在调用完 - (void)prepareToPlayWithCompletion: 后才能访问到正常的值
@property (nonatomic, strong, nullable) UIView *playerView;

+ (nullable instancetype)playerWithURL:(nullable NSURL *)url;
Expand Down
Binary file modified Pod/Library/lib/libPLPlayerKit.a
Binary file not shown.
Binary file modified Pod/Library/lib/libcommon.a
Binary file not shown.
Binary file modified Pod/Library/lib/libdecoder.a
Binary file not shown.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ __weak typeof(self) wself = self;

## 版本历史

- 2.0.2 ([Release Notes](https://github.com/pili-engineering/PLPlayerKit/blob/master/ReleaseNotes/release-notes-2.0.2.md) && [API Diffs](https://github.com/pili-engineering/PLPlayerKit/blob/master/APIDiffs/api-diffs-2.0.2.md))
- 添加 RTMP Cache 机制
- 添加数据超时属性
- 修复 RTMP 播放内存 leak
- 修复 RTMP 播放音频错误问题
- 修复 RTMP 播放主线程卡死问题
- 优化架构,减少内存和 cpu 占用
- 2.0.1 ([Release Notes](https://github.com/pili-engineering/PLPlayerKit/blob/master/ReleaseNotes/release-notes-2.0.1.md) && [API Diffs](https://github.com/pili-engineering/PLPlayerKit/blob/master/APIDiffs/api-diffs-2.0.1.md))
- 修复 `contentMode` 设置无效的问题
- 修复 rtmp 无法播放或播放超时时无 error 抛出的问题
Expand Down
26 changes: 26 additions & 0 deletions ReleaseNotes/release-notes-2.0.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# PLPlayerKit Release Notes for 2.0.2

## 内容

- [简介](#简介)
- [问题反馈](#问题反馈)
- [记录](#记录)

## 简介

PLPlayerKit 为 iOS 开发者提供直播播放 SDK。

## 问题反馈

当你遇到任何问题时,可以通过在 GitHub 的 repo 提交 ```issues``` 来反馈问题,请尽可能的描述清楚遇到的问题,如果有错误信息也一同附带,并且在 ```Labels``` 中指明类型为 bug 或者其他。

[通过这里查看已有的 issues 和提交 Bug](https://github.com/pili-engineering/PLPlayerKit/issues)

## Player

- 添加 RTMP Cache 机制
- 添加数据超时属性
- 修复 RTMP 播放内存 leak
- 修复 RTMP 播放音频错误问题
- 修复 RTMP 播放主线程卡死问题
- 优化架构,减少内存和 cpu 占用

0 comments on commit 5499b21

Please sign in to comment.