添加自定义播放器
This commit is contained in:
parent
55e63072cd
commit
c438d862cf
@ -19,6 +19,8 @@
|
|||||||
006B61D32BBAA938003FCB49 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 006B61D22BBAA938003FCB49 /* StoreKit.framework */; };
|
006B61D32BBAA938003FCB49 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 006B61D22BBAA938003FCB49 /* StoreKit.framework */; };
|
||||||
006B61DC2BBCFAC4003FCB49 /* CustomSheetController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006B61DB2BBCFAC4003FCB49 /* CustomSheetController.swift */; };
|
006B61DC2BBCFAC4003FCB49 /* CustomSheetController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006B61DB2BBCFAC4003FCB49 /* CustomSheetController.swift */; };
|
||||||
006B61DE2BBCFB45003FCB49 /* CustomSheetCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006B61DD2BBCFB45003FCB49 /* CustomSheetCell.swift */; };
|
006B61DE2BBCFB45003FCB49 /* CustomSheetCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006B61DD2BBCFB45003FCB49 /* CustomSheetCell.swift */; };
|
||||||
|
0073BD142BCE80F700721885 /* ZZHCustomPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0073BD132BCE80F700721885 /* ZZHCustomPlayer.swift */; };
|
||||||
|
0073BD182BCF7B3400721885 /* ZZHCustomSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0073BD172BCF7B3400721885 /* ZZHCustomSlider.swift */; };
|
||||||
009661F82BAD6C7100FCA65F /* CCSpaceAlbumFilterPopView2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 009661F72BAD6C7100FCA65F /* CCSpaceAlbumFilterPopView2.swift */; };
|
009661F82BAD6C7100FCA65F /* CCSpaceAlbumFilterPopView2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 009661F72BAD6C7100FCA65F /* CCSpaceAlbumFilterPopView2.swift */; };
|
||||||
009661FA2BAD876200FCA65F /* PhotosUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 009661F92BAD876200FCA65F /* PhotosUI.framework */; };
|
009661FA2BAD876200FCA65F /* PhotosUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 009661F92BAD876200FCA65F /* PhotosUI.framework */; };
|
||||||
009661FC2BADB20D00FCA65F /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 009661FB2BADB20D00FCA65F /* CoreMotion.framework */; };
|
009661FC2BADB20D00FCA65F /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 009661FB2BADB20D00FCA65F /* CoreMotion.framework */; };
|
||||||
@ -126,6 +128,8 @@
|
|||||||
006B61D22BBAA938003FCB49 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
|
006B61D22BBAA938003FCB49 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
|
||||||
006B61DB2BBCFAC4003FCB49 /* CustomSheetController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomSheetController.swift; sourceTree = "<group>"; };
|
006B61DB2BBCFAC4003FCB49 /* CustomSheetController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomSheetController.swift; sourceTree = "<group>"; };
|
||||||
006B61DD2BBCFB45003FCB49 /* CustomSheetCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomSheetCell.swift; sourceTree = "<group>"; };
|
006B61DD2BBCFB45003FCB49 /* CustomSheetCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomSheetCell.swift; sourceTree = "<group>"; };
|
||||||
|
0073BD132BCE80F700721885 /* ZZHCustomPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZZHCustomPlayer.swift; sourceTree = "<group>"; };
|
||||||
|
0073BD172BCF7B3400721885 /* ZZHCustomSlider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZZHCustomSlider.swift; sourceTree = "<group>"; };
|
||||||
009661F72BAD6C7100FCA65F /* CCSpaceAlbumFilterPopView2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CCSpaceAlbumFilterPopView2.swift; sourceTree = "<group>"; };
|
009661F72BAD6C7100FCA65F /* CCSpaceAlbumFilterPopView2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CCSpaceAlbumFilterPopView2.swift; sourceTree = "<group>"; };
|
||||||
009661F92BAD876200FCA65F /* PhotosUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PhotosUI.framework; path = System/Library/Frameworks/PhotosUI.framework; sourceTree = SDKROOT; };
|
009661F92BAD876200FCA65F /* PhotosUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PhotosUI.framework; path = System/Library/Frameworks/PhotosUI.framework; sourceTree = SDKROOT; };
|
||||||
009661FB2BADB20D00FCA65F /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = System/Library/Frameworks/CoreMotion.framework; sourceTree = SDKROOT; };
|
009661FB2BADB20D00FCA65F /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = System/Library/Frameworks/CoreMotion.framework; sourceTree = SDKROOT; };
|
||||||
@ -296,6 +300,8 @@
|
|||||||
children = (
|
children = (
|
||||||
1E1EA2932B9364F000A5D5D2 /* CCSpatialVideoDisplayController.swift */,
|
1E1EA2932B9364F000A5D5D2 /* CCSpatialVideoDisplayController.swift */,
|
||||||
009662592BB552E700FCA65F /* CCSpatialVideoDisplayForVideoTask.swift */,
|
009662592BB552E700FCA65F /* CCSpatialVideoDisplayForVideoTask.swift */,
|
||||||
|
0073BD132BCE80F700721885 /* ZZHCustomPlayer.swift */,
|
||||||
|
0073BD172BCF7B3400721885 /* ZZHCustomSlider.swift */,
|
||||||
);
|
);
|
||||||
path = CCSpatialVideoDisplayController;
|
path = CCSpatialVideoDisplayController;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -816,6 +822,7 @@
|
|||||||
AF2120C32B4E95DA00400B7F /* NSObject+Add.swift in Sources */,
|
AF2120C32B4E95DA00400B7F /* NSObject+Add.swift in Sources */,
|
||||||
1EE5C5F72B8F973A00EDFC2F /* CCSpatialShootController.swift in Sources */,
|
1EE5C5F72B8F973A00EDFC2F /* CCSpatialShootController.swift in Sources */,
|
||||||
006B61DE2BBCFB45003FCB49 /* CustomSheetCell.swift in Sources */,
|
006B61DE2BBCFB45003FCB49 /* CustomSheetCell.swift in Sources */,
|
||||||
|
0073BD142BCE80F700721885 /* ZZHCustomPlayer.swift in Sources */,
|
||||||
1EFB8C782B88E2F600C72119 /* UIColor+CCExtension.swift in Sources */,
|
1EFB8C782B88E2F600C72119 /* UIColor+CCExtension.swift in Sources */,
|
||||||
00D33BF62B99A19900604A44 /* SpatialVideoConvertor.swift in Sources */,
|
00D33BF62B99A19900604A44 /* SpatialVideoConvertor.swift in Sources */,
|
||||||
CBBE190C2BC929F50095F6C4 /* FeedBackVC.swift in Sources */,
|
CBBE190C2BC929F50095F6C4 /* FeedBackVC.swift in Sources */,
|
||||||
@ -859,6 +866,7 @@
|
|||||||
0096625A2BB552E700FCA65F /* CCSpatialVideoDisplayForVideoTask.swift in Sources */,
|
0096625A2BB552E700FCA65F /* CCSpatialVideoDisplayForVideoTask.swift in Sources */,
|
||||||
1EFB8C702B88DA4800C72119 /* CCBottomMenuCell.swift in Sources */,
|
1EFB8C702B88DA4800C72119 /* CCBottomMenuCell.swift in Sources */,
|
||||||
AF2120FA2B4EA5BD00400B7F /* CCHomeController.swift in Sources */,
|
AF2120FA2B4EA5BD00400B7F /* CCHomeController.swift in Sources */,
|
||||||
|
0073BD182BCF7B3400721885 /* ZZHCustomSlider.swift in Sources */,
|
||||||
00ED6B342BA04AC200915BDE /* PlayByTransferConvertor.swift in Sources */,
|
00ED6B342BA04AC200915BDE /* PlayByTransferConvertor.swift in Sources */,
|
||||||
AF2121072B4EA63000400B7F /* CCHomeData.swift in Sources */,
|
AF2121072B4EA63000400B7F /* CCHomeData.swift in Sources */,
|
||||||
AF2120FE2B4EA5F100400B7F /* CCLoginController.swift in Sources */,
|
AF2120FE2B4EA5F100400B7F /* CCLoginController.swift in Sources */,
|
||||||
|
|||||||
Binary file not shown.
@ -14,9 +14,9 @@
|
|||||||
filePath = "SwiftProject/Project/Controller/CCHomeController.swift"
|
filePath = "SwiftProject/Project/Controller/CCHomeController.swift"
|
||||||
startingColumnNumber = "9223372036854775807"
|
startingColumnNumber = "9223372036854775807"
|
||||||
endingColumnNumber = "9223372036854775807"
|
endingColumnNumber = "9223372036854775807"
|
||||||
startingLineNumber = "571"
|
startingLineNumber = "584"
|
||||||
endingLineNumber = "571"
|
endingLineNumber = "584"
|
||||||
landmarkName = "imagePickerController(_:didFinishPickingPhotos:sourceAssets:isSelectOriginalPhoto:infos:)"
|
landmarkName = "imagePickerController(_:didFinishPickingMediaWithInfo:)"
|
||||||
landmarkType = "7">
|
landmarkType = "7">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
</BreakpointProxy>
|
</BreakpointProxy>
|
||||||
@ -30,10 +30,10 @@
|
|||||||
filePath = "SwiftProject/Project/Controller/CCHomeController.swift"
|
filePath = "SwiftProject/Project/Controller/CCHomeController.swift"
|
||||||
startingColumnNumber = "9223372036854775807"
|
startingColumnNumber = "9223372036854775807"
|
||||||
endingColumnNumber = "9223372036854775807"
|
endingColumnNumber = "9223372036854775807"
|
||||||
startingLineNumber = "563"
|
startingLineNumber = "576"
|
||||||
endingLineNumber = "563"
|
endingLineNumber = "576"
|
||||||
landmarkName = "imagePickerController(_:didFinishPickingPhotos:sourceAssets:isSelectOriginalPhoto:infos:)"
|
landmarkName = "CCHomeController"
|
||||||
landmarkType = "7">
|
landmarkType = "21">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
</BreakpointProxy>
|
</BreakpointProxy>
|
||||||
<BreakpointProxy
|
<BreakpointProxy
|
||||||
@ -94,9 +94,9 @@
|
|||||||
filePath = "SwiftProject/Project/Controller/CCHomeController.swift"
|
filePath = "SwiftProject/Project/Controller/CCHomeController.swift"
|
||||||
startingColumnNumber = "9223372036854775807"
|
startingColumnNumber = "9223372036854775807"
|
||||||
endingColumnNumber = "9223372036854775807"
|
endingColumnNumber = "9223372036854775807"
|
||||||
startingLineNumber = "527"
|
startingLineNumber = "540"
|
||||||
endingLineNumber = "527"
|
endingLineNumber = "540"
|
||||||
landmarkName = "imagePickerController(_:didFinishPickingMediaWithInfo:)"
|
landmarkName = "gotoVideoTransformVC(url:asset:)"
|
||||||
landmarkType = "7">
|
landmarkType = "7">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
</BreakpointProxy>
|
</BreakpointProxy>
|
||||||
@ -457,102 +457,6 @@
|
|||||||
landmarkType = "7">
|
landmarkType = "7">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
</BreakpointProxy>
|
</BreakpointProxy>
|
||||||
<BreakpointProxy
|
|
||||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
|
||||||
<BreakpointContent
|
|
||||||
uuid = "D37B77BA-EBC8-4DD9-BE5F-E0FF53223C57"
|
|
||||||
shouldBeEnabled = "No"
|
|
||||||
ignoreCount = "0"
|
|
||||||
continueAfterRunningActions = "No"
|
|
||||||
filePath = "SwiftProject/Project/Controller/RecordingVideo/CCSpatialVideoDisplayController/CCSpatialVideoDisplayForVideoTask.swift"
|
|
||||||
startingColumnNumber = "9223372036854775807"
|
|
||||||
endingColumnNumber = "9223372036854775807"
|
|
||||||
startingLineNumber = "52"
|
|
||||||
endingLineNumber = "52"
|
|
||||||
landmarkName = "convertFrame(request:)"
|
|
||||||
landmarkType = "7">
|
|
||||||
<Locations>
|
|
||||||
<Location
|
|
||||||
uuid = "D37B77BA-EBC8-4DD9-BE5F-E0FF53223C57 - e6cc3a15a2d9caad"
|
|
||||||
shouldBeEnabled = "Yes"
|
|
||||||
ignoreCount = "0"
|
|
||||||
continueAfterRunningActions = "No"
|
|
||||||
symbolName = "SwiftProject.CCSpatialVideoDisplayController.convertFrame(request: __C.AVAsynchronousCIImageFilteringRequest) -> ()"
|
|
||||||
moduleName = "SwiftProject"
|
|
||||||
usesParentBreakpointCondition = "Yes"
|
|
||||||
urlString = "file:///Users/aaa/Documents/IOS%20Dev/VR/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialVideoDisplayController/CCSpatialVideoDisplayForVideoTask.swift"
|
|
||||||
startingColumnNumber = "9223372036854775807"
|
|
||||||
endingColumnNumber = "9223372036854775807"
|
|
||||||
startingLineNumber = "83"
|
|
||||||
endingLineNumber = "83"
|
|
||||||
offsetFromSymbolStart = "556">
|
|
||||||
</Location>
|
|
||||||
<Location
|
|
||||||
uuid = "D37B77BA-EBC8-4DD9-BE5F-E0FF53223C57 - e6cc3a15a2d9caad"
|
|
||||||
shouldBeEnabled = "Yes"
|
|
||||||
ignoreCount = "0"
|
|
||||||
continueAfterRunningActions = "No"
|
|
||||||
symbolName = "SwiftProject.CCSpatialVideoDisplayController.convertFrame(request: __C.AVAsynchronousCIImageFilteringRequest) -> ()"
|
|
||||||
moduleName = "SwiftProject"
|
|
||||||
usesParentBreakpointCondition = "Yes"
|
|
||||||
urlString = "file:///Users/aaa/Documents/IOS%20Dev/VR/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialVideoDisplayController/CCSpatialVideoDisplayForVideoTask.swift"
|
|
||||||
startingColumnNumber = "9223372036854775807"
|
|
||||||
endingColumnNumber = "9223372036854775807"
|
|
||||||
startingLineNumber = "83"
|
|
||||||
endingLineNumber = "83"
|
|
||||||
offsetFromSymbolStart = "524">
|
|
||||||
</Location>
|
|
||||||
</Locations>
|
|
||||||
</BreakpointContent>
|
|
||||||
</BreakpointProxy>
|
|
||||||
<BreakpointProxy
|
|
||||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
|
||||||
<BreakpointContent
|
|
||||||
uuid = "C3AB3C59-7E1D-4AE8-8D10-25F7B54C5B5B"
|
|
||||||
shouldBeEnabled = "No"
|
|
||||||
ignoreCount = "0"
|
|
||||||
continueAfterRunningActions = "No"
|
|
||||||
filePath = "SwiftProject/Project/Controller/RecordingVideo/CCSpatialVideoDisplayController/CCSpatialVideoDisplayForVideoTask.swift"
|
|
||||||
startingColumnNumber = "9223372036854775807"
|
|
||||||
endingColumnNumber = "9223372036854775807"
|
|
||||||
startingLineNumber = "57"
|
|
||||||
endingLineNumber = "57"
|
|
||||||
landmarkName = "convertFrame(request:)"
|
|
||||||
landmarkType = "7">
|
|
||||||
<Locations>
|
|
||||||
<Location
|
|
||||||
uuid = "C3AB3C59-7E1D-4AE8-8D10-25F7B54C5B5B - e6cc3a15a2d9cb11"
|
|
||||||
shouldBeEnabled = "Yes"
|
|
||||||
ignoreCount = "0"
|
|
||||||
continueAfterRunningActions = "No"
|
|
||||||
symbolName = "SwiftProject.CCSpatialVideoDisplayController.convertFrame(request: __C.AVAsynchronousCIImageFilteringRequest) -> ()"
|
|
||||||
moduleName = "SwiftProject"
|
|
||||||
usesParentBreakpointCondition = "Yes"
|
|
||||||
urlString = "file:///Users/aaa/Documents/IOS%20Dev/VR/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialVideoDisplayController/CCSpatialVideoDisplayForVideoTask.swift"
|
|
||||||
startingColumnNumber = "9223372036854775807"
|
|
||||||
endingColumnNumber = "9223372036854775807"
|
|
||||||
startingLineNumber = "87"
|
|
||||||
endingLineNumber = "87"
|
|
||||||
offsetFromSymbolStart = "668">
|
|
||||||
</Location>
|
|
||||||
<Location
|
|
||||||
uuid = "C3AB3C59-7E1D-4AE8-8D10-25F7B54C5B5B - e6cc3a15a2d9cb11"
|
|
||||||
shouldBeEnabled = "Yes"
|
|
||||||
ignoreCount = "0"
|
|
||||||
continueAfterRunningActions = "No"
|
|
||||||
symbolName = "SwiftProject.CCSpatialVideoDisplayController.convertFrame(request: __C.AVAsynchronousCIImageFilteringRequest) -> ()"
|
|
||||||
moduleName = "SwiftProject"
|
|
||||||
usesParentBreakpointCondition = "Yes"
|
|
||||||
urlString = "file:///Users/aaa/Documents/IOS%20Dev/VR/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialVideoDisplayController/CCSpatialVideoDisplayForVideoTask.swift"
|
|
||||||
startingColumnNumber = "9223372036854775807"
|
|
||||||
endingColumnNumber = "9223372036854775807"
|
|
||||||
startingLineNumber = "87"
|
|
||||||
endingLineNumber = "87"
|
|
||||||
offsetFromSymbolStart = "564">
|
|
||||||
</Location>
|
|
||||||
</Locations>
|
|
||||||
</BreakpointContent>
|
|
||||||
</BreakpointProxy>
|
|
||||||
<BreakpointProxy
|
<BreakpointProxy
|
||||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
<BreakpointContent
|
<BreakpointContent
|
||||||
|
|||||||
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
21
SwiftProject/SwiftProject/Assets.xcassets/customPlayer/slider_thumb.imageset/Contents.json
vendored
Normal file
21
SwiftProject/SwiftProject/Assets.xcassets/customPlayer/slider_thumb.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "未命名.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
SwiftProject/SwiftProject/Assets.xcassets/customPlayer/slider_thumb.imageset/未命名.png
vendored
Normal file
BIN
SwiftProject/SwiftProject/Assets.xcassets/customPlayer/slider_thumb.imageset/未命名.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1017 B |
@ -0,0 +1,60 @@
|
|||||||
|
//
|
||||||
|
// ZZHCustomPlayer.swift
|
||||||
|
// SwiftProject
|
||||||
|
//
|
||||||
|
// Created by aaa on 2024/4/16.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import UIKit
|
||||||
|
import AVKit
|
||||||
|
class ZZHCustomPlayer: UIView {
|
||||||
|
var playerLayerBgView:UIView?
|
||||||
|
var avPlayer:AVPlayer?
|
||||||
|
var avPlayerLayer:AVPlayerLayer?
|
||||||
|
var timeSlider:ZZHCustomSlider?
|
||||||
|
|
||||||
|
|
||||||
|
override init(frame: CGRect) {
|
||||||
|
super.init(frame: frame)
|
||||||
|
let playerWidth = KScreenWidth
|
||||||
|
let playerHeight = 200
|
||||||
|
playerLayerBgView = UIView()
|
||||||
|
self.addSubview(playerLayerBgView!)
|
||||||
|
playerLayerBgView!.snp.makeConstraints { make in
|
||||||
|
make.left.right.equalToSuperview()
|
||||||
|
make.centerY.equalToSuperview()
|
||||||
|
make.height.equalTo(playerHeight)
|
||||||
|
}
|
||||||
|
avPlayer = AVPlayer()
|
||||||
|
avPlayerLayer = AVPlayerLayer(player: avPlayer)
|
||||||
|
avPlayerLayer?.frame = CGRect(x: 0, y: 0, width: Int(playerWidth), height: playerHeight)
|
||||||
|
playerLayerBgView!.layer.addSublayer(avPlayerLayer!)
|
||||||
|
playerLayerBgView?.backgroundColor = UIColor.orange
|
||||||
|
|
||||||
|
timeSlider = ZZHCustomSlider(frame: .zero)
|
||||||
|
timeSlider?.processChangeValueCallback = { value in
|
||||||
|
print("value:\(value)")
|
||||||
|
}
|
||||||
|
self.addSubview(timeSlider!)
|
||||||
|
timeSlider!.snp.makeConstraints { make in
|
||||||
|
make.left.equalToSuperview().offset(24)
|
||||||
|
make.right.equalToSuperview().offset(-24)
|
||||||
|
make.bottom.equalToSuperview().offset(0)
|
||||||
|
make.height.equalTo(120)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
override func draw(_ rect: CGRect) {
|
||||||
|
super.draw(rect)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,174 @@
|
|||||||
|
//
|
||||||
|
// ZZHCustomSlider..swift
|
||||||
|
// SwiftProject
|
||||||
|
//
|
||||||
|
// Created by aaa on 2024/4/17.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import UIKit
|
||||||
|
typealias CustomSliderProcessChangeValueCallback = (_ currentValue:Float)->Void
|
||||||
|
class ZZHCustomSlider: UIView {
|
||||||
|
var sHeight:CGFloat?
|
||||||
|
var sLabel:UILabel?
|
||||||
|
var eLabel:UILabel?
|
||||||
|
var timeSlider:CustomSlider?
|
||||||
|
var processChangeValueCallback:CustomSliderProcessChangeValueCallback?
|
||||||
|
var preValue:Float = 0.0 //更新进度前的value
|
||||||
|
|
||||||
|
let bgView:UIView = UIView()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
override init(frame: CGRect) {
|
||||||
|
super.init(frame: frame)
|
||||||
|
self.backgroundColor = .black
|
||||||
|
self.addSubview(bgView)
|
||||||
|
bgView.snp.makeConstraints { make in
|
||||||
|
make.left.right.equalToSuperview()
|
||||||
|
make.centerY.equalToSuperview()
|
||||||
|
make.height.equalTo(28)
|
||||||
|
}
|
||||||
|
|
||||||
|
timeSlider = CustomSlider()
|
||||||
|
timeSlider?.isUserInteractionEnabled = false
|
||||||
|
bgView.addSubview(timeSlider!)
|
||||||
|
timeSlider!.snp.makeConstraints { make in
|
||||||
|
make.top.equalToSuperview()
|
||||||
|
make.left.equalToSuperview()
|
||||||
|
make.right.equalToSuperview()
|
||||||
|
}
|
||||||
|
|
||||||
|
sLabel = UILabel()
|
||||||
|
bgView.addSubview(sLabel!)
|
||||||
|
eLabel = UILabel()
|
||||||
|
bgView.addSubview(eLabel!)
|
||||||
|
sLabel?.snp.makeConstraints({ make in
|
||||||
|
make.left.equalTo(timeSlider!.snp.left)
|
||||||
|
make.top.equalTo(timeSlider!.snp.bottom).offset(10)
|
||||||
|
make.bottom.equalToSuperview()
|
||||||
|
})
|
||||||
|
|
||||||
|
eLabel?.snp.makeConstraints({ make in
|
||||||
|
make.right.equalTo(timeSlider!.snp.right)
|
||||||
|
make.top.equalTo(sLabel!.snp.top)
|
||||||
|
make.bottom.equalTo(sLabel!.snp.bottom)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
sLabel?.font = UIFont.systemFont(ofSize: 14)
|
||||||
|
eLabel?.font = UIFont.systemFont(ofSize: 14)
|
||||||
|
|
||||||
|
sLabel?.textColor = .white
|
||||||
|
eLabel?.textColor = .white
|
||||||
|
|
||||||
|
sLabel?.text = "--:--:--"
|
||||||
|
eLabel?.text = "--:--:--"
|
||||||
|
timeSlider?.setThumbImage(UIImage(named: "slider_thumb"), for: .normal)
|
||||||
|
timeSlider?.minimumTrackTintColor = .white
|
||||||
|
timeSlider?.maximumTrackTintColor = UIColor(r: 20, g: 20, b: 20, a: 0.8)
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
//内部拖动更新当前滑块value:0~1
|
||||||
|
func updateProcessValue(value:Float) {
|
||||||
|
self.timeSlider!.value = value
|
||||||
|
guard let processChangeValueCallback else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var currentValue = max(0, min(value, 1))
|
||||||
|
//格式化为0.x
|
||||||
|
let formattedValue = String(format: "%.1f", currentValue)
|
||||||
|
currentValue = Float(formattedValue)!
|
||||||
|
|
||||||
|
if currentValue > preValue || currentValue < preValue {
|
||||||
|
preValue = currentValue
|
||||||
|
processChangeValueCallback(preValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//外部播放时的更新当前滑块
|
||||||
|
func exUpdateProcessValue(value:Float) {
|
||||||
|
self.timeSlider!.value = value
|
||||||
|
preValue = value
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||||
|
super.touchesMoved(touches, with: event)
|
||||||
|
if timeSlider!.isNormal == true {
|
||||||
|
timeSlider!.isNormal = false
|
||||||
|
sHeight = self.bgView.height
|
||||||
|
self.updateSliderHeight(height: (self.sHeight)! + 5)
|
||||||
|
}
|
||||||
|
let touch = touches.first
|
||||||
|
if let th = touch {
|
||||||
|
let touchPoint = th.location(in: self.timeSlider!)
|
||||||
|
|
||||||
|
updateProcessValue(value: Float(touchPoint.x / self.timeSlider!.frame.size.width))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||||
|
super.touchesEnded(touches, with: event)
|
||||||
|
if timeSlider!.isNormal == false {
|
||||||
|
timeSlider!.isNormal = true
|
||||||
|
self.updateSliderHeight(height: (self.sHeight)!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||||
|
if timeSlider!.isNormal == false {
|
||||||
|
timeSlider!.isNormal = true
|
||||||
|
self.updateSliderHeight(height: (self.sHeight)!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func updateSliderHeight(height:CGFloat) {
|
||||||
|
UIView.animate(withDuration: 0.25) {[weak self] in
|
||||||
|
self?.bgView.snp.updateConstraints {make in
|
||||||
|
make.height.equalTo(height)
|
||||||
|
}
|
||||||
|
self?.layoutIfNeeded()
|
||||||
|
} completion: { finish in
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class CustomSlider: UISlider {
|
||||||
|
var isNormal:Bool = true {
|
||||||
|
didSet {
|
||||||
|
self.setNeedsLayout()
|
||||||
|
self.layoutIfNeeded()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override func trackRect(forBounds bounds: CGRect) -> CGRect {
|
||||||
|
var rect = super.trackRect(forBounds: bounds)
|
||||||
|
if isNormal == true {
|
||||||
|
rect = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, 8)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rect = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, 10)
|
||||||
|
}
|
||||||
|
return rect
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// override func thumbRect(forBounds bounds: CGRect, trackRect rect: CGRect, value: Float) -> CGRect {
|
||||||
|
// var nb = super.thumbRect(forBounds: bounds, trackRect: rect, value: value)
|
||||||
|
// nb = CGRectMake(nb.origin.x, nb.origin.y, 1, 1)
|
||||||
|
// return nb
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user