IRPlayer 0.3.6

IRPlayer 0.3.6

irons163 维护。



IRPlayer 0.3.6

  • irons163

Build Status Platform

IRPlayer

IRPlayer 是一款用于 iOS 的强大视频播放框架。

  • 使用 IRPlayer 播放视频。
    • 查看演示。
  • 使用 IRPlayer 创建具有自定义 UI 的视频播放器。
  • 使用 IRPlayer 播放网络摄像头流。
  • 使用 IRPlayer 制作屏幕录制器。
  • 使用 IRPlayer 制作 RTMP 流。
  • 使用 IRPlayer 制作具有效果的播放器。
  • 实时直播应用。

特性

  • 支持普通视频模式。
  • 支持 VR 模式。
  • 支持 VR 盒子模式。
  • 支持鱼眼模式。
    • 支持普通鱼眼模式。
    • 支持鱼眼到全景模式。
    • 支持鱼眼到透视模式。
  • 支持多窗口。
  • 支持多模式选择。

安装

Cocoapods

  • Podfile 中添加 pod 'IRPlayer', '~> 0.3.2'
  • pod install

使用方法

  • 更多示例在演示应用中。

基本操作

self.player = [IRPlayerImp player];
[self.mainView insertSubview:self.player.view atIndex:0];

NSURL * normalVideo = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"i-see-fire" ofType:@"mp4"]];
NSURL * vrVideo = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"google-help-vr" ofType:@"mp4"]];
NSURL * fisheyeVideo = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"fisheye-demo" ofType:@"mp4"]];

设置模式和视频源

switch (self.demoType)
{
    case DemoType_AVPlayer_Normal:
        [self.player replaceVideoWithURL:normalVideo];
        break;
    case DemoType_AVPlayer_VR:
        [self.player replaceVideoWithURL:vrVideo videoType:IRVideoTypeVR];
        break;
    case DemoType_AVPlayer_VR_Box:
        self.player.displayMode = IRDisplayModeBox;
        [self.player replaceVideoWithURL:vrVideo videoType:IRVideoTypeVR];
        break;
    case DemoType_FFmpeg_Normal:
        self.player.decoder.mpeg4Format = IRDecoderTypeFFmpeg;
        self.player.decoder.ffmpegHardwareDecoderEnable = NO;
        [self.player replaceVideoWithURL:normalVideo];
        break;
    case DemoType_FFmpeg_Normal_Hardware:
        self.player.decoder = [IRPlayerDecoder FFmpegDecoder];
        [self.player replaceVideoWithURL:normalVideo];
        break;
    case DemoType_FFmpeg_Fisheye_Hardware:
        self.player.decoder = [IRPlayerDecoder FFmpegDecoder];
        [self.player replaceVideoWithURL:fisheyeVideo videoType:IRVideoTypeFisheye];
        break;
    case DemoType_FFmpeg_Fisheye_Hardware_Modes_Selection:
        self.player.decoder = [IRPlayerDecoder FFmpegDecoder];
        [self.player replaceVideoWithURL:fisheyeVideo videoType:IRVideoTypeFisheye];
        break;
}

高级设置

NSArray *modes = [self createFisheyeModesWithParameter:nil];
self.player.renderModes = modes;
[self.player replaceVideoWithURL:fisheyeVideo videoType:IRVideoTypeCustom];


- (NSArray<IRGLRenderMode*> *)createFisheyeModesWithParameter:(nullable IRMediaParameter *)parameter {
    IRGLRenderMode *normal = [[IRGLRenderMode2D alloc] init];
    IRGLRenderMode *fisheye2Pano = [[IRGLRenderMode2DFisheye2Pano alloc] init];
    IRGLRenderMode *fisheye = [[IRGLRenderMode3DFisheye alloc] init];
    IRGLRenderMode *fisheye4P = [[IRGLRenderModeMulti4P alloc] init];
    NSArray<IRGLRenderMode*>* modes = @[
    fisheye2Pano,
    fisheye,
    fisheye4P,
    normal
    ];

    normal.shiftController.enabled = NO;

    fisheye2Pano.contentMode = IRGLRenderContentModeScaleAspectFill;
    fisheye2Pano.wideDegreeX = 360;
    fisheye2Pano.wideDegreeY = 20;

    fisheye4P.parameter = fisheye.parameter = [[IRFisheyeParameter alloc] initWithWidth:0 height:0 up:NO rx:0 ry:0 cx:0 cy:0 latmax:80];
    fisheye4P.aspect = fisheye.aspect = 16.0 / 9.0;

    normal.name = @"Rawdata";
    fisheye2Pano.name = @"Panorama";
    fisheye.name = @"Onelen";
    fisheye4P.name = @"Fourlens";

    return modes;
}

截图

普通 VR
Normal VR
VR盒 鱼眼360
VR Box Fisheye 360
全景 模式选择
Panorama Modes Selection
多窗口
Multi Windows

版权

本项目借鉴了来自SGPlayer的一些基本代码。

IRPlayer项目部分版权由Single持有,2017年。IRPlayer项目的其余版权由irons163持有,2019年。