去掉打印,然后就是修复横屏后player bg的高度错误
This commit is contained in:
parent
9810af4c01
commit
40ff5ead6e
@ -90,7 +90,7 @@ class ZZHCustomPlayer: UIView {
|
|||||||
|
|
||||||
self.playBtn.snp.makeConstraints { make in
|
self.playBtn.snp.makeConstraints { make in
|
||||||
make.centerX.centerY.equalToSuperview()
|
make.centerX.centerY.equalToSuperview()
|
||||||
make.width.height.equalTo(80)
|
make.width.height.equalTo(40)
|
||||||
}
|
}
|
||||||
return bgView
|
return bgView
|
||||||
}()
|
}()
|
||||||
@ -146,6 +146,7 @@ class ZZHCustomPlayer: UIView {
|
|||||||
let playerWidth = KScreenWidth
|
let playerWidth = KScreenWidth
|
||||||
|
|
||||||
playerLayerBgView = UIView()
|
playerLayerBgView = UIView()
|
||||||
|
playerLayerBgView?.backgroundColor = .clear
|
||||||
self.addSubview(playerLayerBgView!)
|
self.addSubview(playerLayerBgView!)
|
||||||
playerLayerBgView!.snp.makeConstraints { make in
|
playerLayerBgView!.snp.makeConstraints { make in
|
||||||
make.left.right.equalToSuperview()
|
make.left.right.equalToSuperview()
|
||||||
@ -162,6 +163,8 @@ class ZZHCustomPlayer: UIView {
|
|||||||
})
|
})
|
||||||
|
|
||||||
avPlayerLayer = AVPlayerLayer(player: avPlayer)
|
avPlayerLayer = AVPlayerLayer(player: avPlayer)
|
||||||
|
// avPlayerLayer?.backgroundColor = UIColor.brown.cgColor
|
||||||
|
|
||||||
avPlayerLayer?.frame = CGRect(x: 0, y: 0, width: Int(playerWidth), height: playerHeight)
|
avPlayerLayer?.frame = CGRect(x: 0, y: 0, width: Int(playerWidth), height: playerHeight)
|
||||||
avPlayerLayer?.videoGravity = .resizeAspect
|
avPlayerLayer?.videoGravity = .resizeAspect
|
||||||
playerLayerBgView!.layer.addSublayer(avPlayerLayer!)
|
playerLayerBgView!.layer.addSublayer(avPlayerLayer!)
|
||||||
@ -210,7 +213,6 @@ class ZZHCustomPlayer: UIView {
|
|||||||
make.left.equalTo(timeSlider!.snp.right).offset(24)
|
make.left.equalTo(timeSlider!.snp.right).offset(24)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateEDBtnHeight() {
|
func updateEDBtnHeight() {
|
||||||
@ -235,7 +237,7 @@ class ZZHCustomPlayer: UIView {
|
|||||||
timeSlider?.isHidden = false
|
timeSlider?.isHidden = false
|
||||||
edBtn?.isHidden = false
|
edBtn?.isHidden = false
|
||||||
playerLayerBgView?.snp.updateConstraints { make in
|
playerLayerBgView?.snp.updateConstraints { make in
|
||||||
make.height.equalTo(KScreenWidth)
|
make.height.equalTo(playerHeight)
|
||||||
}
|
}
|
||||||
self.layoutIfNeeded()
|
self.layoutIfNeeded()
|
||||||
avPlayerLayer?.frame = CGRect(x: 0, y: 0, width: Int(KScreenWidth), height: playerHeight)
|
avPlayerLayer?.frame = CGRect(x: 0, y: 0, width: Int(KScreenWidth), height: playerHeight)
|
||||||
|
|||||||
@ -262,12 +262,12 @@ class PlayByTransferConvertor {
|
|||||||
//获取调整了瞳距的图片
|
//获取调整了瞳距的图片
|
||||||
let x_offset = CGFloat(abs(ed) * edS) //关于瞳距的x偏移量
|
let x_offset = CGFloat(abs(ed) * edS) //关于瞳距的x偏移量
|
||||||
let imageWidth = left.size.width*0.5 - x_offset
|
let imageWidth = left.size.width*0.5 - x_offset
|
||||||
print("imageWidth:\(imageWidth) ,left.size.width*0.5:\(left.size.width*0.5) ")
|
// print("imageWidth:\(imageWidth) ,left.size.width*0.5:\(left.size.width*0.5) ")
|
||||||
let imageHeight = left.size.height
|
let imageHeight = left.size.height
|
||||||
let (ed_left,last_left_size) = getImgWithED(image: n_left, drawImgWidth: imageWidth,drawSize: n_left_size)
|
let (ed_left,last_left_size) = getImgWithED(image: n_left, drawImgWidth: imageWidth,drawSize: n_left_size)
|
||||||
let (ed_right,last_right_size) = getImgWithED(image: n_right, drawImgWidth: imageWidth,drawSize: n_right_size)
|
let (ed_right,last_right_size) = getImgWithED(image: n_right, drawImgWidth: imageWidth,drawSize: n_right_size)
|
||||||
print("n_left_size:\(n_left_size)\nlast_left_size\(last_left_size)")
|
// print("n_left_size:\(n_left_size)\nlast_left_size\(last_left_size)")
|
||||||
print("n_right_size:\(n_right_size)\nlast_right_size\(last_right_size)")
|
// print("n_right_size:\(n_right_size)\nlast_right_size\(last_right_size)")
|
||||||
// testImageUi(image: ed_left)
|
// testImageUi(image: ed_left)
|
||||||
let newImageSize = left.size
|
let newImageSize = left.size
|
||||||
UIGraphicsBeginImageContextWithOptions(newImageSize, false, 1)
|
UIGraphicsBeginImageContextWithOptions(newImageSize, false, 1)
|
||||||
@ -276,12 +276,12 @@ class PlayByTransferConvertor {
|
|||||||
ed_left.draw(in: CGRect(x:0, y:(imageHeight - last_left_size.height) * 0.5, width:last_left_size.width, height:last_left_size.height))
|
ed_left.draw(in: CGRect(x:0, y:(imageHeight - last_left_size.height) * 0.5, width:last_left_size.width, height:last_left_size.height))
|
||||||
ed_right.draw(in: CGRect(x:newImageSize.width - last_right_size.width, y:(imageHeight - last_right_size.height) * 0.5, width:last_right_size.width, height:last_right_size.height))
|
ed_right.draw(in: CGRect(x:newImageSize.width - last_right_size.width, y:(imageHeight - last_right_size.height) * 0.5, width:last_right_size.width, height:last_right_size.height))
|
||||||
|
|
||||||
print("ed>>>>> 0....")
|
// print("ed>>>>> 0....")
|
||||||
}
|
}
|
||||||
else if (ed < 0) {
|
else if (ed < 0) {
|
||||||
ed_left.draw(in: CGRect(x:newImageSize.width*0.5 - last_left_size.width, y:(imageHeight - n_left_size.height) * 0.5, width:last_left_size.width, height:last_left_size.height))
|
ed_left.draw(in: CGRect(x:newImageSize.width*0.5 - last_left_size.width, y:(imageHeight - n_left_size.height) * 0.5, width:last_left_size.width, height:last_left_size.height))
|
||||||
ed_right.draw(in: CGRect(x:newImageSize.width*0.5, y:(imageHeight - n_right_size.height) * 0.5, width:last_right_size.width, height:last_right_size.height))
|
ed_right.draw(in: CGRect(x:newImageSize.width*0.5, y:(imageHeight - n_right_size.height) * 0.5, width:last_right_size.width, height:last_right_size.height))
|
||||||
print("ed < 0....")
|
// print("ed < 0....")
|
||||||
}
|
}
|
||||||
else {//瞳距没有改变的情况
|
else {//瞳距没有改变的情况
|
||||||
let leftRect = CGRect(x:(imageWidth - n_left_size.width) * 0.5, y:(imageHeight - n_left_size.height) * 0.5 , width:n_left_size.width, height:n_left_size.height)
|
let leftRect = CGRect(x:(imageWidth - n_left_size.width) * 0.5, y:(imageHeight - n_left_size.height) * 0.5 , width:n_left_size.width, height:n_left_size.height)
|
||||||
@ -290,7 +290,7 @@ class PlayByTransferConvertor {
|
|||||||
let rightRect = CGRect(x:imageWidth + (imageWidth - n_right_size.width) * 0.5 , y:(imageHeight - n_right_size.height) * 0.5, width:n_right_size.width, height:n_right_size.height)
|
let rightRect = CGRect(x:imageWidth + (imageWidth - n_right_size.width) * 0.5 , y:(imageHeight - n_right_size.height) * 0.5, width:n_right_size.width, height:n_right_size.height)
|
||||||
ed_right.draw(in:rightRect )
|
ed_right.draw(in:rightRect )
|
||||||
|
|
||||||
print("newImageSize:\(newImageSize) \nimageWidth:\(imageWidth) \ned_left.size:\(ed_left.size) \nleftRect:\(leftRect) \nrightRect:\(rightRect)")
|
// print("newImageSize:\(newImageSize) \nimageWidth:\(imageWidth) \ned_left.size:\(ed_left.size) \nleftRect:\(leftRect) \nrightRect:\(rightRect)")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -335,10 +335,10 @@ class PlayByTransferConvertor {
|
|||||||
func getImgWithED(image:UIImage,drawImgWidth:CGFloat,drawSize:CGSize) -> (UIImage,CGSize) {
|
func getImgWithED(image:UIImage,drawImgWidth:CGFloat,drawSize:CGSize) -> (UIImage,CGSize) {
|
||||||
if drawSize.width <= drawImgWidth {
|
if drawSize.width <= drawImgWidth {
|
||||||
|
|
||||||
print("瞳距返回,不用处理")
|
// print("瞳距返回,不用处理")
|
||||||
return (image,drawSize)
|
return (image,drawSize)
|
||||||
}
|
}
|
||||||
print("瞳距要处理")
|
// print("瞳距要处理")
|
||||||
// let s = drawSize.height / image.size.height
|
// let s = drawSize.height / image.size.height
|
||||||
let newImageWidth = drawImgWidth * image.size.height / drawSize.height
|
let newImageWidth = drawImgWidth * image.size.height / drawSize.height
|
||||||
let dRect = CGRectMake((image.size.width - newImageWidth) * 0.5, 0, newImageWidth, image.size.height)
|
let dRect = CGRectMake((image.size.width - newImageWidth) * 0.5, 0, newImageWidth, image.size.height)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user