The last article briefly introduced the iJkPlayer framework and gave an example. Today is a day to dig deeper into the iJkPlayer framework. 😀 😀 😀
Take a look at the results:
This frame is still used in the previous article, just grab it.
Take a look at the overall project structure:
(1) Separate the dataSource and delegate of the UITableView as usual to facilitate code writing and future maintenance.
Implement a LIST scrolling 3D animation in the delegate:
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
Cell.layer. transform = CATransform3DMakeScale(0.1, 0.1, 1);
[UIView animateWithDuration:1 animations:^{
cell.layer.transform = CATransform3DMakeScale(1, 1, 1);
}];
}
Copy the code
(2) Screen scrolling navigation bar looming
Here I use KVO to achieve this effect:
Registration:
[_dataTableView addObserver: self forKeyPath: @"contentOffset" options: NSKeyValueObservingOptionNew context: nil];
Implementation method:
//KVO listens for screen scrolling
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context
{
UIPanGestureRecognizer* pan = _dataTableView.panGestureRecognizer;
// Get drag speed >0 drag down <0 drag up
CGFloat velocity = [pan velocityInView:_dataTableView].y;
if (velocity<-5) {
// Drag up to hide the navigation bar
[self.navigationController setNavigationBarHidden:true animated:true];
}
else if (velocity>5) {
// Drag down to display the navigation bar
[self.navigationController setNavigationBarHidden:false animated:true];
}
else if(velocity==0){
// Stop dragging
}
}
Copy the code
(3) Talk about broadcasting
Initialize the Player object and complete the related Settings
self.url = [NSURL URLWithString:_liveUrl];
_player = [[IJKFFMoviePlayerController alloc] initWithContentURL:self.url withOptions:nil];
Copy the code
Register notifications && Remove notifications
Registration:
- (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];
}
Copy the code
Removed:
- (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];
}
Copy the code
The Demo address: https://github.com/hejintaochenxin/blue
Note: Since git can’t upload a single file over 100M, I have removed this file from the project. You can refer to the link at the top of this article to create it yourself, or you can send it to you directly. You just need to drag it into the project
Here’s a great framework for streaming right now: SmarterStreaming
https://github.com/daniulive/SmarterStreaming
- Attention should be paid to integration:
(1) Real machine test
(2)
1. Compile time find libSmartPlayerSDK. A, please first to SmartiOSPlayer/SmartiOSPlayer directory, unzip libSmartPlayerSDK. Zip.
2. Compile time find libSmartPublisherSDK. A, please first to SmartiOSPublisher/SmartiOSPublisher/libs directory, unzip libSmartPublisherSDK. Zip.
Copy the code