|
@@ -87,7 +87,6 @@ public class PQMovieInput: ImageSource {
|
|
public var readingShouldWait = false
|
|
public var readingShouldWait = false
|
|
public var videoInputStatusObserver: NSKeyValueObservation?
|
|
public var videoInputStatusObserver: NSKeyValueObservation?
|
|
public var audioInputStatusObserver: NSKeyValueObservation?
|
|
public var audioInputStatusObserver: NSKeyValueObservation?
|
|
-// var audioPlayerObserver : NSKeyValueObservation?
|
|
|
|
var avPlayerTimeObserver: NSKeyValueObservation?
|
|
var avPlayerTimeObserver: NSKeyValueObservation?
|
|
|
|
|
|
public var useRealtimeThreads = false
|
|
public var useRealtimeThreads = false
|
|
@@ -184,12 +183,8 @@ public class PQMovieInput: ImageSource {
|
|
public convenience init(url: URL, playAtActualSpeed: Bool = false, loop: Bool = false, audioSettings: [String: Any]? = nil) throws {
|
|
public convenience init(url: URL, playAtActualSpeed: Bool = false, loop: Bool = false, audioSettings: [String: Any]? = nil) throws {
|
|
let inputAsset = AVURLAsset(url: url, options: nil)
|
|
let inputAsset = AVURLAsset(url: url, options: nil)
|
|
try self.init(asset: inputAsset, videoComposition: nil, audioMix: nil, playAtActualSpeed: playAtActualSpeed, loop: loop, audioSettings: audioSettings)
|
|
try self.init(asset: inputAsset, videoComposition: nil, audioMix: nil, playAtActualSpeed: playAtActualSpeed, loop: loop, audioSettings: audioSettings)
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
// 析构方法
|
|
// 析构方法
|
|
deinit {
|
|
deinit {
|
|
self.movieFramebuffer?.unlock()
|
|
self.movieFramebuffer?.unlock()
|
|
@@ -259,8 +254,6 @@ public class PQMovieInput: ImageSource {
|
|
self.start(isFreeBuffer: true,timeRange: playeTimeRange)
|
|
self.start(isFreeBuffer: true,timeRange: playeTimeRange)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
|
|
if let movieOutput = self.synchronizedMovieOutput {
|
|
if let movieOutput = self.synchronizedMovieOutput {
|
|
self.conditionLock.lock()
|
|
self.conditionLock.lock()
|
|
@@ -689,7 +682,7 @@ extension PQMovieInput {
|
|
self.musicPlayRanges = ranges
|
|
self.musicPlayRanges = ranges
|
|
let playerItem = AVPlayerItem(url: assetUrl)
|
|
let playerItem = AVPlayerItem(url: assetUrl)
|
|
avPlayer = AVPlayer.init(playerItem: playerItem)
|
|
avPlayer = AVPlayer.init(playerItem: playerItem)
|
|
- let range = ranges.first
|
|
|
|
|
|
+// let range = ranges.first
|
|
// 当前版本设置无限大
|
|
// 当前版本设置无限大
|
|
let loopCount = 10000 // ranges.count
|
|
let loopCount = 10000 // ranges.count
|
|
|
|
|
|
@@ -702,11 +695,11 @@ extension PQMovieInput {
|
|
}
|
|
}
|
|
// strongSelf.indexRage += 1
|
|
// strongSelf.indexRage += 1
|
|
|
|
|
|
- if strongSelf.indexRage < loopCount && strongSelf.isPlay {
|
|
|
|
|
|
+ if strongSelf.indexRage < loopCount && strongSelf.isPlay && CMTimeGetSeconds(strongSelf.playeTimeRange.end) > CMTimeGetSeconds((strongSelf.musicPlayRanges?.first!.end)!) {
|
|
|
|
|
|
- let range = ranges[strongSelf.indexRage]
|
|
|
|
- playerItem.forwardPlaybackEndTime = range.end
|
|
|
|
- playerItem.reversePlaybackEndTime = range.start
|
|
|
|
|
|
+ let range = strongSelf.musicPlayRanges?[strongSelf.indexRage]
|
|
|
|
+ playerItem.forwardPlaybackEndTime = range!.end
|
|
|
|
+ playerItem.reversePlaybackEndTime = range!.start
|
|
// HHZPrint("curr: start ********************\(CMTimeGetSeconds(range.start)) - \(playerItem.reversePlaybackEndTime) - \(playerItem.forwardPlaybackEndTime)")
|
|
// HHZPrint("curr: start ********************\(CMTimeGetSeconds(range.start)) - \(playerItem.reversePlaybackEndTime) - \(playerItem.forwardPlaybackEndTime)")
|
|
strongSelf.avPlayer!.seek(to: playerItem.reversePlaybackEndTime) { isSuccess in
|
|
strongSelf.avPlayer!.seek(to: playerItem.reversePlaybackEndTime) { isSuccess in
|
|
playerItem.seek(to: playerItem.reversePlaybackEndTime) { isSuccess in
|
|
playerItem.seek(to: playerItem.reversePlaybackEndTime) { isSuccess in
|
|
@@ -728,7 +721,7 @@ extension PQMovieInput {
|
|
let playerItem = self.avPlayer?.currentItem
|
|
let playerItem = self.avPlayer?.currentItem
|
|
let rangeee = CMTimeRangeMake(start: playeTimeRange.start, duration: self.musicPlayRanges?.first?.duration ?? CMTime(value: 1200, timescale: 40))
|
|
let rangeee = CMTimeRangeMake(start: playeTimeRange.start, duration: self.musicPlayRanges?.first?.duration ?? CMTime(value: 1200, timescale: 40))
|
|
playerItem?.reversePlaybackEndTime = rangeee.start
|
|
playerItem?.reversePlaybackEndTime = rangeee.start
|
|
- playerItem?.forwardPlaybackEndTime = self.musicPlayRanges?.first?.end ?? CMTime(value: 4000, timescale: 40)
|
|
|
|
|
|
+ playerItem?.forwardPlaybackEndTime = CMTimeMinimum(self.musicPlayRanges?.first?.end ?? CMTime(value: 1000, timescale: 1), playeTimeRange.end)
|
|
|
|
|
|
playerItem?.seek(to: playerItem!.reversePlaybackEndTime) { [weak self]_ in
|
|
playerItem?.seek(to: playerItem!.reversePlaybackEndTime) { [weak self]_ in
|
|
self?.avPlayer?.play()
|
|
self?.avPlayer?.play()
|