- Use IRPlayer to play video.
- See demo.
- Use IRPlayer to make video player with custom UI.
- See IRPlayerUIShell
- Use IRPlayer to play IP Camera stream.
- See IRIPCamera
- Use IRPlayer to make Screen Recoder.
- See IRRecoder
- Use IRPlayer to make RTMP streaming.
- See IRLiveKit
- Use IRPlayer to make video player with effects .
- See IREffectPlayer
- Real Live player App.
- See IRLive
- Support Normal video mode.
- Support VR mode.
- Support VR Box mode.
- Support Fisheye mode.
- Support Normal Fisheye mode.
- Support Fisheye to Panorama mode.
- Support Fisheye to Perspective mode.
- Support multi windows.
- Support multi modes selection.
- Support set the specific renders to each mode.
- Support custom video input(IRFFVideoInput). See what it works in IRIPCamera.
- Support custom display view(inherit IRGLView). See what it works in IREffectPlayer.
- Support SPM.
- Add package: https://github.com/irons163/IRPlayer-swift
The following two ways could let you get started quickly without any build errors.
- Run the
SPMDemo
which inside this project. OR - Run this simplest implement to valid
IRPlayer-swift
.
import UIKit
import IRPlayerSwift
class ViewController: UIViewController {
var player = IRPlayerImp.player()
override func viewDidLoad() {
super.viewDidLoad()
if let view = player.view {
self.view.addSubview(view)
}
player.replaceVideoWithURL(contentURL: NSURL(string: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"))
player.play()
}
}
lazy var player: IRPlayerImp = {
return IRPlayerImp.player()
}()
self.player.registerPlayerNotification(target: self,
stateAction: #selector(stateAction(_:)),
progressAction: #selector(progressAction(_:)),
playableAction: #selector(playableAction(_:)),
errorAction: #selector(errorAction(_:)))
self.player.viewTapAction = { (player, view) in
print("player display view did click!")
}
if let playerView = self.player.view {
self.mainView.insertSubview(playerView, at: 0)
}
switch self.demoType {
case .avPlayerNormal:
self.player.replaceVideoWithURL(contentURL: PlayerViewController.normalVideo as NSURL)
case .avPlayerVR:
self.player.replaceVideoWithURL(contentURL: PlayerViewController.vrVideo as NSURL)
case .avPlayerVRBox:
self.player.displayMode = .box
self.player.replaceVideoWithURL(contentURL: PlayerViewController.vrVideo as NSURL)
case .ffmpegNormal:
self.player.decoder.mpeg4Format = .ffmpeg
self.player.decoder.ffmpegHardwareDecoderEnable = false
self.player.replaceVideoWithURL(contentURL: PlayerViewController.normalVideo as NSURL)
case .ffmpegNormalHardware:
self.player.decoder = IRPlayerDecoder.FFmpegDecoder()
self.player.replaceVideoWithURL(contentURL: PlayerViewController.normalVideo as NSURL)
case .ffmpegFisheyeHardware:
self.player.decoder = IRPlayerDecoder.FFmpegDecoder()
self.player.replaceVideoWithURL(contentURL: PlayerViewController.fisheyeVideo as NSURL)
case .ffmpegPanoramaHardware:
self.player.decoder = IRPlayerDecoder.FFmpegDecoder()
self.player.replaceVideoWithURL(contentURL: PlayerViewController.fisheyeVideo as NSURL)
case .ffmpegMultiModesHardwareModesSelection:
self.player.decoder = IRPlayerDecoder.FFmpegDecoder()
modes = self.createFisheyeModes(with: nil)
let sharedRender = IRGLRenderNV12()
for mode in modes ?? [] {
mode.renderer = sharedRender;
}
self.player.renderModes = modes
self.player.replaceVideoWithURL(contentURL: PlayerViewController.fisheyeVideo as NSURL)
self.modesButton.isHidden = false
}
- Send video frames directly.
let input = IRFFVideoInput()
self.player.replaceVideoWithInput(input, videoType: .normal)
......
var yuvFrame = IRFFAVYUVVideoFrame()
/*
setup the yuvFrame.
*/
input.send(videoFrame: yuvFrame)
- Send video frames by your own decode implement.
- See how it works in IRIPCamera-swift.
class MyIRFFVideoInput: IRFFVideoInput {
override func videoDecoder(_ videoDecoder: IRFFVideoDecoderInfo, decodeFrame packet: AVPacket) -> IRFFVideoFrame? {
asyncHWDecode()
return nil // if it is sync decode instead, return videoFrame from here.
}
func asyncHWDecode() {
Task {
// let videoFrame = ......
self.videoOutput?.send?(videoFrame: videoFrame)
}
}
}
NSArray *modes = [self createFisheyeModesWithParameter:nil];
self.player.renderModes = modes;
[self.player replaceVideoWithURL:fisheyeVideo videoType:IRVideoTypeCustom];
func createFisheyeModes(with parameter: IRMediaParameter?) -> [IRGLRenderMode] {
let normal = IRGLRenderMode2D()
let fisheye2Pano = IRGLRenderMode2DFisheye2Pano()
let fisheye = IRGLRenderMode3DFisheye()
let fisheye4P = IRGLRenderModeMulti4P()
let modes = [
fisheye2Pano,
fisheye,
fisheye4P,
normal
]
normal.shiftController.enabled = false
fisheye2Pano.contentMode = .scaleAspectFill
fisheye2Pano.wideDegreeX = 360
fisheye2Pano.wideDegreeY = 20
fisheye4P.parameter = IRFisheyeParameter(width: 0, height: 0, up: false, rx: 0, ry: 0, cx: 0, cy: 0, latmax: 80)
fisheye.parameter = fisheye4P.parameter
fisheye4P.aspect = 16.0 / 9.0
fisheye.aspect = fisheye4P.aspect
normal.name = "Rawdata"
fisheye2Pano.name = "Panorama"
fisheye.name = "Onelen"
fisheye4P.name = "Fourlens"
return modes
}
Normal | VR | VR Box | Fisheye 360 |
---|---|---|---|
Panorama | Modes Selection | Multi Windows | |
Mac Player 1 | Mac Player 2 |
---|---|