Skip to content

Commit

Permalink
Merge pull request #45 from HHK1/swift5
Browse files Browse the repository at this point in the history
update project for swift 5.0
  • Loading branch information
HHK1 authored Apr 8, 2019
2 parents 767ddc4 + f8615c1 commit b6b3897
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 31 deletions.
6 changes: 3 additions & 3 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- PryntTrimmerView (3.0.0)
- PryntTrimmerView (4.0.0)

DEPENDENCIES:
- PryntTrimmerView (from `../`)
Expand All @@ -9,8 +9,8 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
PryntTrimmerView: ca0f9fb8627ef407543d4db52686a38f50a47a5b
PryntTrimmerView: 67e67573ffd4c073f1308effa66aefd0cfa667a0

PODFILE CHECKSUM: 9a57d3190d5a70bb58c3d64123970e379115ef99

COCOAPODS: 1.5.3
COCOAPODS: 1.6.1
21 changes: 12 additions & 9 deletions Example/PryntTrimmerView.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 1000;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
Expand All @@ -351,6 +351,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -400,7 +401,7 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-PryntTrimmerView_Example/Pods-PryntTrimmerView_Example-frameworks.sh",
"${PODS_ROOT}/Target Support Files/Pods-PryntTrimmerView_Example/Pods-PryntTrimmerView_Example-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/PryntTrimmerView/PryntTrimmerView.framework",
);
name = "[CP] Embed Pods Frameworks";
Expand All @@ -409,7 +410,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-PryntTrimmerView_Example/Pods-PryntTrimmerView_Example-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-PryntTrimmerView_Example/Pods-PryntTrimmerView_Example-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
A8367BFE47826B5DFE1DB321 /* [CP] Check Pods Manifest.lock */ = {
Expand Down Expand Up @@ -533,6 +534,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -591,6 +593,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -651,7 +654,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.prynt.trimmerView;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -668,7 +671,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.prynt.trimmerView;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -690,7 +693,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -708,7 +711,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down Expand Up @@ -739,7 +742,7 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -771,7 +774,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.prynt.PryntTrimmerView;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1000"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1000"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Example/PryntTrimmerView/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
Expand Down
22 changes: 11 additions & 11 deletions Example/PryntTrimmerView/VideoCropperViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ class VideoCropperViewController: AssetSelectionViewController {

if let selectedTime = selectThumbView.selectedTime, let asset = videoCropView.asset {
let generator = AVAssetImageGenerator(asset: asset)
generator.requestedTimeToleranceBefore = kCMTimeZero
generator.requestedTimeToleranceAfter = kCMTimeZero
generator.requestedTimeToleranceBefore = CMTime.zero
generator.requestedTimeToleranceAfter = CMTime.zero
generator.appliesPreferredTrackTransform = true
var actualTime = kCMTimeZero
var actualTime = CMTime.zero
let image = try? generator.copyCGImage(at: selectedTime, actualTime: &actualTime)
if let image = image {

Expand All @@ -69,24 +69,24 @@ class VideoCropperViewController: AssetSelectionViewController {

let assetComposition = AVMutableComposition()
let frame1Time = CMTime(seconds: 0.2, preferredTimescale: asset.duration.timescale)
let trackTimeRange = CMTimeRangeMake(kCMTimeZero, frame1Time)
let trackTimeRange = CMTimeRangeMake(start: .zero, duration: frame1Time)

guard let videoCompositionTrack = assetComposition.addMutableTrack(withMediaType: .video,
preferredTrackID: kCMPersistentTrackID_Invalid) else {
return
}

try videoCompositionTrack.insertTimeRange(trackTimeRange, of: videoTrack, at: kCMTimeZero)
try videoCompositionTrack.insertTimeRange(trackTimeRange, of: videoTrack, at: CMTime.zero)

if let audioTrack = asset.tracks(withMediaType: AVMediaType.audio).first {
let audioCompositionTrack = assetComposition.addMutableTrack(withMediaType: AVMediaType.audio,
preferredTrackID: kCMPersistentTrackID_Invalid)
try audioCompositionTrack?.insertTimeRange(trackTimeRange, of: audioTrack, at: kCMTimeZero)
try audioCompositionTrack?.insertTimeRange(trackTimeRange, of: audioTrack, at: CMTime.zero)
}

//1. Create the instructions
let mainInstructions = AVMutableVideoCompositionInstruction()
mainInstructions.timeRange = CMTimeRangeMake(kCMTimeZero, asset.duration)
mainInstructions.timeRange = CMTimeRangeMake(start: .zero, duration: asset.duration)

//2 add the layer instructions
let layerInstructions = AVMutableVideoCompositionLayerInstruction(assetTrack: videoCompositionTrack)
Expand All @@ -95,16 +95,16 @@ class VideoCropperViewController: AssetSelectionViewController {
height: 16 * videoCropView.aspectRatio.height * 18)
let transform = getTransform(for: videoTrack)

layerInstructions.setTransform(transform, at: kCMTimeZero)
layerInstructions.setOpacity(1.0, at: kCMTimeZero)
layerInstructions.setTransform(transform, at: CMTime.zero)
layerInstructions.setOpacity(1.0, at: CMTime.zero)
mainInstructions.layerInstructions = [layerInstructions]

//3 Create the main composition and add the instructions

let videoComposition = AVMutableVideoComposition()
videoComposition.renderSize = renderSize
videoComposition.instructions = [mainInstructions]
videoComposition.frameDuration = CMTimeMake(1, 30)
videoComposition.frameDuration = CMTimeMake(value: 1, timescale: 30)

let url = URL(fileURLWithPath: "\(NSTemporaryDirectory())TrimmedMovie.mp4")
try? FileManager.default.removeItem(at: url)
Expand Down Expand Up @@ -165,7 +165,7 @@ class VideoCropperViewController: AssetSelectionViewController {
extension VideoCropperViewController: ThumbSelectorViewDelegate {

func didChangeThumbPosition(_ imageTime: CMTime) {
videoCropView.player?.seek(to: imageTime, toleranceBefore: kCMTimeZero, toleranceAfter: kCMTimeZero)
videoCropView.player?.seek(to: imageTime, toleranceBefore: CMTime.zero, toleranceAfter: CMTime.zero)
}
}

Expand Down
6 changes: 3 additions & 3 deletions Example/PryntTrimmerView/VideoTrimmerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,23 @@ class VideoTrimmerViewController: AssetSelectionViewController {
trimmerView.seek(to: playBackTime)

if playBackTime >= endTime {
player.seek(to: startTime, toleranceBefore: kCMTimeZero, toleranceAfter: kCMTimeZero)
player.seek(to: startTime, toleranceBefore: CMTime.zero, toleranceAfter: CMTime.zero)
trimmerView.seek(to: startTime)
}
}
}

extension VideoTrimmerViewController: TrimmerViewDelegate {
func positionBarStoppedMoving(_ playerTime: CMTime) {
player?.seek(to: playerTime, toleranceBefore: kCMTimeZero, toleranceAfter: kCMTimeZero)
player?.seek(to: playerTime, toleranceBefore: CMTime.zero, toleranceAfter: CMTime.zero)
player?.play()
startPlaybackTimeChecker()
}

func didChangePositionBar(_ playerTime: CMTime) {
stopPlaybackTimeChecker()
player?.pause()
player?.seek(to: playerTime, toleranceBefore: kCMTimeZero, toleranceAfter: kCMTimeZero)
player?.seek(to: playerTime, toleranceBefore: CMTime.zero, toleranceAfter: CMTime.zero)
let duration = (trimmerView.endTime! - trimmerView.startTime!).seconds
print(duration)
}
Expand Down
4 changes: 2 additions & 2 deletions PryntTrimmerView.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'PryntTrimmerView'
s.version = '3.0.0'
s.version = '4.0.0'
s.summary = 'A set of tools written in swift to help you trim and crop a video.'

s.description = <<-DESC
Expand All @@ -23,6 +23,6 @@ Second tool is a crop view, to preview a video and select the part of the video
s.source = { :git => 'https://github.com/HHK1/PryntTrimmerView.git', :tag => s.version.to_s }
s.ios.deployment_target = '9.0'
s.source_files = 'PryntTrimmerView/Classes/**/*'
s.swift_version = '4.2'
s.swift_version = '5.0'

end

0 comments on commit b6b3897

Please sign in to comment.