Skip to content

Commit

Permalink
update swift 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
VeinGuo committed Nov 6, 2018
1 parent 61e0337 commit 511c98c
Show file tree
Hide file tree
Showing 43 changed files with 700 additions and 559 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ playground.xcworkspace
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build
Carthage/

# fastlane
#
Expand Down
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0
4.2
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "SnapKit/SnapKit" ~> 3.2.0
github "SnapKit/SnapKit" ~> 4.2.0
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "SnapKit/SnapKit" "3.2.0"
github "SnapKit/SnapKit" "4.2.0"
4 changes: 2 additions & 2 deletions VGPlayer.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ Pod::Spec.new do |s|

s.ios.deployment_target = "8.0"
s.platform = :ios, "8.0"
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.0' }
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.2' }

s.source = { :git => "https://github.com/VeinGuo/VGPlayer.git", :tag => s.version }
s.source_files = 'VGPlayer/Classes/*.*', 'VGPlayer/Classes/**/*.*'
s.resources = 'VGPlayer/*.xcassets'
s.requires_arc = true
s.dependency 'SnapKit', '~> 4.0.0'
s.dependency 'SnapKit', '~> 4.2.0'
s.frameworks = 'UIKit', 'AVFoundation', 'Foundation'

end
Expand Down
33 changes: 26 additions & 7 deletions VGPlayer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

/* Begin PBXBuildFile section */
336DDBC71EE5075A004BDE6F /* VGPlayerLoadingIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 336DDBC61EE5075A004BDE6F /* VGPlayerLoadingIndicator.swift */; };
33A448371F09F15C002103B4 /* SnapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33A448361F09F15C002103B4 /* SnapKit.framework */; };
33B36A9C1EE5327500F9BC2B /* VGPlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33B36A9B1EE5327500F9BC2B /* VGPlayerView.swift */; };
33D264DA1EEE74A800A42DDA /* Timer+VGPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33D264D91EEE74A800A42DDA /* Timer+VGPlayer.swift */; };
8001CB2F1EDD7D4E00C6C9D2 /* VGPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8001CB2E1EDD7D4E00C6C9D2 /* VGPlayer.swift */; };
Expand All @@ -29,6 +28,7 @@
807A46EF1EDC706100A99141 /* VGPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 807A46E51EDC706100A99141 /* VGPlayer.framework */; };
807A46F41EDC706100A99141 /* VGPlayerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 807A46F31EDC706100A99141 /* VGPlayerTests.swift */; };
807A46F61EDC706100A99141 /* VGPlayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 807A46E81EDC706100A99141 /* VGPlayer.h */; settings = {ATTRIBUTES = (Public, ); }; };
80AF1E3C2191EC1F00A73925 /* SnapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33A448361F09F15C002103B4 /* SnapKit.framework */; };
80B21B411EF5489C009E00EA /* VGSubtitles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80B21B401EF5489C009E00EA /* VGSubtitles.swift */; };
80D923A21EE4368600564FFD /* VGPlayerError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80D923A01EE4368600564FFD /* VGPlayerError.swift */; };
80D923A31EE4368600564FFD /* VGPlayerSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80D923A11EE4368600564FFD /* VGPlayerSlider.swift */; };
Expand Down Expand Up @@ -84,7 +84,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
33A448371F09F15C002103B4 /* SnapKit.framework in Frameworks */,
80AF1E3C2191EC1F00A73925 /* SnapKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -240,7 +240,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 0830;
LastUpgradeCheck = 1010;
ORGANIZATIONNAME = Vein;
TargetAttributes = {
807A46E41EDC706100A99141 = {
Expand All @@ -250,6 +250,7 @@
};
807A46ED1EDC706100A99141 = {
CreatedOnToolsVersion = 8.3;
LastSwiftMigration = 1010;
ProvisioningStyle = Automatic;
};
};
Expand Down Expand Up @@ -349,15 +350,23 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -403,15 +412,23 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -461,7 +478,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 1;
};
name = Debug;
Expand All @@ -486,7 +503,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.Vein.VGPlayer;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 1;
};
name = Release;
Expand All @@ -499,7 +516,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.Vein.VGPlayerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -511,7 +529,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.Vein.VGPlayerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
4 changes: 2 additions & 2 deletions VGPlayer/Classes/MediaCache/VGPlayerCacheManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ open class VGPlayerCacheManager: NSObject {
static public let VGPlayerCacheErrorKey: String = "VGPlayerCacheErrorKey"
static public let VGPlayerCleanCacheKey: String = "VGPlayerCleanCacheKey"

open static var mediaCacheNotifyInterval = 0.1
public static var mediaCacheNotifyInterval = 0.1

fileprivate let ioQueue = DispatchQueue(label: "com.vgplayer.ioQueue")
fileprivate var fileManager: FileManager!

open static let shared = VGPlayerCacheManager()
public static let shared = VGPlayerCacheManager()
open private(set) var cacheConfig = VGPlayerCacheConfiguration()

public override init() {
Expand Down
2 changes: 1 addition & 1 deletion VGPlayer/Classes/MediaCache/VGPlayerCacheMediaWorker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ open class VGPlayerCacheMediaWorker: NSObject {

open func startWritting() {
if !isWritting {
NotificationCenter.default.addObserver(self, selector: #selector(applicationDidEnterBackground(_:)), name: .UIApplicationDidEnterBackground, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(applicationDidEnterBackground(_:)), name:UIApplication.didEnterBackgroundNotification , object: nil)
}
isWritting = true
starWriteDate = NSDate()
Expand Down
20 changes: 10 additions & 10 deletions VGPlayer/Classes/VGPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ extension VGPlayer {
guard let strongSelf = self else { return }
strongSelf.seeking = true
strongSelf.startPlayerBuffering()
strongSelf.playerItem?.seek(to: CMTimeMakeWithSeconds(time, Int32(NSEC_PER_SEC)), completionHandler: { (finished) in
strongSelf.playerItem?.seek(to: CMTimeMakeWithSeconds(time, preferredTimescale: Int32(NSEC_PER_SEC)), completionHandler: { (finished) in
DispatchQueue.main.async {
strongSelf.seeking = false
strongSelf.stopPlayerBuffering()
Expand Down Expand Up @@ -327,8 +327,8 @@ extension VGPlayer {

internal func addPlayerNotifications() {
NotificationCenter.default.addObserver(self, selector: .playerItemDidPlayToEndTime, name: .AVPlayerItemDidPlayToEndTime, object: nil)
NotificationCenter.default.addObserver(self, selector: .applicationWillEnterForeground, name: .UIApplicationWillEnterForeground, object: nil)
NotificationCenter.default.addObserver(self, selector: .applicationDidEnterBackground, name: .UIApplicationDidEnterBackground, object: nil)
NotificationCenter.default.addObserver(self, selector: .applicationWillEnterForeground, name: UIApplication.willEnterForegroundNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: .applicationDidEnterBackground, name: UIApplication.didEnterBackgroundNotification, object: nil)
}

internal func removePlayerItemObservers() {
Expand All @@ -339,8 +339,8 @@ extension VGPlayer {

internal func removePlayerNotifations() {
NotificationCenter.default.removeObserver(self, name: .AVPlayerItemDidPlayToEndTime, object: nil)
NotificationCenter.default.removeObserver(self, name: .UIApplicationWillEnterForeground, object: nil)
NotificationCenter.default.removeObserver(self, name: .UIApplicationDidEnterBackground, object: nil)
NotificationCenter.default.removeObserver(self, name: UIApplication.willEnterForegroundNotification, object: nil)
NotificationCenter.default.removeObserver(self, name: UIApplication.didEnterBackgroundNotification, object: nil)
}


Expand Down Expand Up @@ -390,19 +390,19 @@ extension VGPlayer {
if (context == &playerItemContext) {

if keyPath == #keyPath(AVPlayerItem.status) {
let status: AVPlayerItemStatus
let status: AVPlayerItem.Status
if let statusNumber = change?[.newKey] as? NSNumber {
status = AVPlayerItemStatus(rawValue: statusNumber.intValue)!
status = AVPlayerItem.Status(rawValue: statusNumber.intValue)!
} else {
status = .unknown
}

switch status {
case AVPlayerItemStatus.unknown:
case .unknown:
startPlayerBuffering()
case AVPlayerItemStatus.readyToPlay:
case .readyToPlay:
bufferState = .readyToPlay
case AVPlayerItemStatus.failed:
case .failed:
state = .error
collectPlayerErrorLogEvent()
stopPlayerBuffering()
Expand Down
6 changes: 3 additions & 3 deletions VGPlayer/Classes/VGPlayerLoadingIndicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ open class VGPlayerLoadingIndicator: UIView {
}

internal func commonInit(){
timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
setupIndicatorLayer()
}

internal func setupIndicatorLayer() {
indicatorLayer.strokeColor = UIColor.white.cgColor
indicatorLayer.fillColor = nil
indicatorLayer.lineWidth = 2.0
indicatorLayer.lineJoin = kCALineJoinRound;
indicatorLayer.lineCap = kCALineCapRound;
indicatorLayer.lineJoin = CAShapeLayerLineJoin.round;
indicatorLayer.lineCap = CAShapeLayerLineCap.round;
layer.addSublayer(indicatorLayer)
updateIndicatorLayerPath()
}
Expand Down
14 changes: 7 additions & 7 deletions VGPlayer/Classes/VGPlayerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ open class VGPlayerView: UIView {
return label
}()
open var closeButton : UIButton = {
let button = UIButton(type: UIButtonType.custom)
let button = UIButton(type: .custom)
return button
}()

Expand All @@ -88,11 +88,11 @@ open class VGPlayerView: UIView {
}()
open var timeSlider = VGPlayerSlider ()
open var loadingIndicator = VGPlayerLoadingIndicator()
open var fullscreenButton : UIButton = UIButton(type: UIButtonType.custom)
open var fullscreenButton : UIButton = UIButton(type: .custom)
open var timeLabel : UILabel = UILabel()
open var playButtion : UIButton = UIButton(type: UIButtonType.custom)
open var playButtion : UIButton = UIButton(type: .custom)
open var volumeSlider : UISlider!
open var replayButton : UIButton = UIButton(type: UIButtonType.custom)
open var replayButton : UIButton = UIButton(type: .custom)
open fileprivate(set) var panGestureDirection : VGPlayerViewPanGestureDirection = .horizontal
fileprivate var isVolume : Bool = false
fileprivate var sliderSeekTimeValue : TimeInterval = .nan
Expand Down Expand Up @@ -339,7 +339,7 @@ extension VGPlayerView {
}, repeats: false)
}
internal func addDeviceOrientationNotifications() {
NotificationCenter.default.addObserver(self, selector: #selector(deviceOrientationWillChange(_:)), name: .UIApplicationWillChangeStatusBarOrientation, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(deviceOrientationWillChange(_:)), name: UIApplication.willChangeStatusBarOrientationNotification, object: nil)
}

internal func configurationVolumeSlider() {
Expand Down Expand Up @@ -476,8 +476,8 @@ extension VGPlayerView {
let velocity = gesture.velocity(in: self)
switch gesture.state {
case .began:
let x = fabs(translation.x)
let y = fabs(translation.y)
let x = abs(translation.x)
let y = abs(translation.y)
if x < y {
panGestureDirection = .vertical
if location.x > bounds.width / 2 {
Expand Down
6 changes: 3 additions & 3 deletions VGPlayer/Classes/VGSubtitles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ open class VGSubtitles {
var index = 0
do {
let regex = try NSRegularExpression(pattern: regxString, options: .caseInsensitive)
let matches = regex.matches(in: payload, options: NSRegularExpression.MatchingOptions(rawValue: 0), range: NSMakeRange(0, payload.characters.count))
let matches = regex.matches(in: payload, options: NSRegularExpression.MatchingOptions(rawValue: 0), range: NSMakeRange(0, payload.count))
for matche in matches {
let group = (payload as NSString).substring(with: matche.range)
let regex = try NSRegularExpression(pattern: "\\d{1,2}:\\d{1,2}:\\d{1,2}[,.]\\d{1,3}", options: .caseInsensitive)
let match = regex.matches(in: group, options: NSRegularExpression.MatchingOptions(rawValue: 0), range: NSMakeRange(0, group.characters.count))
let match = regex.matches(in: group, options: NSRegularExpression.MatchingOptions(rawValue: 0), range: NSMakeRange(0, group.count))
guard let start = match.first, let end = match.last else {
continue
}
Expand All @@ -143,7 +143,7 @@ open class VGSubtitles {

// content before
let contentRegex = try NSRegularExpression(pattern: "[0-9]*,[0-9]*,[^,.]*,[^,.]*,[0-9]*,[0-9]*,", options: .caseInsensitive)
let contentMatch = contentRegex.matches(in: group, options: NSRegularExpression.MatchingOptions(rawValue: 0), range: NSMakeRange(0, group.characters.count))
let contentMatch = contentRegex.matches(in: group, options: NSRegularExpression.MatchingOptions(rawValue: 0), range: NSMakeRange(0, group.count))

guard let text = contentMatch.first else {
continue
Expand Down
18 changes: 11 additions & 7 deletions VGPlayerExample/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
PODS:
- SnapKit (4.0.0)
- VGPlayer (0.1.5):
- SnapKit (~> 4.0.0)
- SnapKit (4.2.0)
- VGPlayer (0.2.0):
- SnapKit (~> 4.2.0)

DEPENDENCIES:
- VGPlayer (from `../`)

SPEC REPOS:
https://github.com/cocoapods/specs.git:
- SnapKit

EXTERNAL SOURCES:
VGPlayer:
:path: ../
:path: "../"

SPEC CHECKSUMS:
SnapKit: a42d492c16e80209130a3379f73596c3454b7694
VGPlayer: a43ba18c023f926b680d23a8e853aa773f855904
SnapKit: fe8a619752f3f27075cc9a90244d75c6c3f27e2a
VGPlayer: 0caf8058ef019d869005d7246a1f03c76acfe731

PODFILE CHECKSUM: 42836598836d22df90bc314686421f150d136f4c

COCOAPODS: 1.3.1
COCOAPODS: 1.5.2
Loading

0 comments on commit 511c98c

Please sign in to comment.