Skip to content

Commit

Permalink
Merge pull request HHK1#50 from RemyLivewall/master
Browse files Browse the repository at this point in the history
Public API changes
  • Loading branch information
HHK1 authored Nov 15, 2019
2 parents 8e3374a + c2b223b commit a342dfa
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ DerivedData
Carthage

Pods/

#Jetbrains IDE
.idea/
7 changes: 7 additions & 0 deletions PryntTrimmerView/Classes/Parents/AVAssetTimeSelector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ public class AVAssetTimeSelector: UIView, UIScrollViewDelegate {

let assetPreview = AssetVideoScrollView()

/// The maximum duration allowed for the trimming. Change it before setting the asset, as the asset preview
public var maxDuration: Double = 15 {
didSet {
assetPreview.maxDuration = maxDuration
}
}

/// The asset to be displayed in the underlying scroll view. Setting a new asset will automatically refresh the thumbnails.
public var asset: AVAsset? {
didSet {
Expand Down
7 changes: 3 additions & 4 deletions PryntTrimmerView/Classes/Parents/AssetVideoScrollView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AssetVideoScrollView: UIScrollView {
private var widthConstraint: NSLayoutConstraint?

let contentView = UIView()
var maxDuration: Double = 15
public var maxDuration: Double = 15
private var generator: AVAssetImageGenerator?

override init(frame: CGRect) {
Expand Down Expand Up @@ -116,7 +116,6 @@ class AssetVideoScrollView: UIScrollView {
}

private func getThumbnailTimes(for asset: AVAsset, numberOfThumbnails: Int) -> [NSValue] {

let timeIncrement = (asset.duration.seconds * 1000) / Double(numberOfThumbnails)
var timesForThumbnails = [NSValue]()
for index in 0..<numberOfThumbnails {
Expand All @@ -128,10 +127,10 @@ class AssetVideoScrollView: UIScrollView {
}

private func generateImages(for asset: AVAsset, at times: [NSValue], with maximumSize: CGSize, visibleThumnails: Int) {

generator = AVAssetImageGenerator(asset: asset)
generator?.appliesPreferredTrackTransform = true
let scaledSize = CGSize(width: maximumSize.width * UIScreen.main.scale, height: maximumSize.height * UIScreen.main.scale)

let scaledSize = CGSize(width: maximumSize.width * UIScreen.main.scale, height: maximumSize.height * UIScreen.main.scale)
generator?.maximumSize = scaledSize
var count = 0

Expand Down
7 changes: 0 additions & 7 deletions PryntTrimmerView/Classes/Trimmer/PryntTrimmerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,6 @@ public protocol TrimmerViewDelegate: class {

private let handleWidth: CGFloat = 15

/// The maximum duration allowed for the trimming. Change it before setting the asset, as the asset preview
public var maxDuration: Double = 15 {
didSet {
assetPreview.maxDuration = maxDuration
}
}

/// The minimum duration allowed for the trimming. The handles won't pan further if the minimum duration is attained.
public var minDuration: Double = 3

Expand Down

0 comments on commit a342dfa

Please sign in to comment.