基于ijkPlayer的網(wǎng)絡(luò)播放器,支持網(wǎng)絡(luò)視頻、RTMP、HLS(m3u8)等多種格式
3分鐘快速集成播放器,支持小屏、全屏模式,無需手動添加任何依賴庫

支持小屏、全屏模式
一、推薦使用CocoaPods方式集成
1、在podfile文件中添加,然后執(zhí)行 pod install操作,文件較大,請耐心等待
pod 'YWVideoPlayer', '~> 1.0.3'
2、AppDelegate.h 文件中加入 fullScreen 屬性,如下
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (nonatomic) BOOL fullScreen;
@end
3、在 AppDelegate.m 文件中 加入橫屏方法(無需調(diào)用)
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
if (self.fullScreen == YES) {
return UIInterfaceOrientationMaskAll;
}
return UIInterfaceOrientationMaskPortrait;
}
4、在播放器控制器界面導(dǎo)入頭文件
Demo 里面是在BasePlayerViewController中引入相關(guān)頭文件
#import "YWMediaPlayerView.h"
5、照著BasePlayerViewController文件中的方式去使用即可
// 這里的SecondViewController是繼承了BasePlayerViewController
#import "SecondViewController.h"
@interface SecondViewController ()
@end
@implementation SecondViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
self.isLiveVideo = YES; // 設(shè)置為直播
[self.view addSubview:self.playerView];
// 測試鏈接 mp4、rtmp、m3u8
// NSString *testUrl = @"http://flv2.bn.netease.com/videolib3/1604/28/fVobI0704/SD/fVobI0704-mobile.mp4";
// NSString *testUrl = @"rtmp://live.hkstv.hk.lxdns.com/live/hks";
NSString *testUrl = @"http://dlhls.cdn.zhanqi.tv/zqlive/49427_jmACJ.m3u8";
[self showPlayerViewWithUrl:testUrl Title:@"視頻的標題"];
// 自動播放
[self autoPlay];
}
@end
Github 地址:https://github.com/90candy/YWVideoPlayer
