iOS開發(fā) - 基于ijkPlayer的播放器框架

基于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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容