|
@@ -50,7 +50,7 @@ class OJAAssetReader: NSObject {
|
|
if trackStatus == AVKeyValueStatus.loaded {
|
|
if trackStatus == AVKeyValueStatus.loaded {
|
|
self.setupTrackOutput(asset: self.urlAsset)
|
|
self.setupTrackOutput(asset: self.urlAsset)
|
|
} else {
|
|
} else {
|
|
- NSLog("loadValuesAsynchronously error: \(error ?? NSError())")
|
|
|
|
|
|
+ WSSSimpleLog("loadValuesAsynchronously error: \(error ?? NSError())")
|
|
}
|
|
}
|
|
semaphore.signal()
|
|
semaphore.signal()
|
|
}
|
|
}
|
|
@@ -63,7 +63,7 @@ class OJAAssetReader: NSObject {
|
|
do {
|
|
do {
|
|
try assetReader = AVAssetReader(asset: asset)
|
|
try assetReader = AVAssetReader(asset: asset)
|
|
} catch {
|
|
} catch {
|
|
- NSLog("creating assetReader error")
|
|
|
|
|
|
+ WSSSimpleLog("creating assetReader error")
|
|
}
|
|
}
|
|
guard let reader = assetReader else {
|
|
guard let reader = assetReader else {
|
|
return
|
|
return
|
|
@@ -71,7 +71,7 @@ class OJAAssetReader: NSObject {
|
|
|
|
|
|
let dict = [kCVPixelBufferPixelFormatTypeKey as String : kCVPixelFormatType_420YpCbCr8BiPlanarFullRange]
|
|
let dict = [kCVPixelBufferPixelFormatTypeKey as String : kCVPixelFormatType_420YpCbCr8BiPlanarFullRange]
|
|
guard let videoTrack = asset.tracks(withMediaType: .video).safeObject(atIndex: 0) else {
|
|
guard let videoTrack = asset.tracks(withMediaType: .video).safeObject(atIndex: 0) else {
|
|
- NSLog("no video track")
|
|
|
|
|
|
+ WSSSimpleLog("no video track")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
let videoTrackOutput = AVAssetReaderTrackOutput(track: videoTrack, outputSettings: dict)
|
|
let videoTrackOutput = AVAssetReaderTrackOutput(track: videoTrack, outputSettings: dict)
|
|
@@ -89,7 +89,7 @@ class OJAAssetReader: NSObject {
|
|
|
|
|
|
let success = reader.startReading()
|
|
let success = reader.startReading()
|
|
if !success {
|
|
if !success {
|
|
- NSLog("reading error: \(String(describing: reader.error)) \n ***\(self.urlAsset)")
|
|
|
|
|
|
+ WSSSimpleLog("reading error: \(String(describing: reader.error)) \n ***\(self.urlAsset)")
|
|
}
|
|
}
|
|
self.lock.unlock()
|
|
self.lock.unlock()
|
|
|
|
|
|
@@ -100,7 +100,7 @@ class OJAAssetReader: NSObject {
|
|
let buffer: CMSampleBuffer? = audioTrackOutput?.copyNextSampleBuffer()
|
|
let buffer: CMSampleBuffer? = audioTrackOutput?.copyNextSampleBuffer()
|
|
|
|
|
|
if let reader = assetReader, reader.status == .completed {
|
|
if let reader = assetReader, reader.status == .completed {
|
|
- NSLog("reader audio completed")
|
|
|
|
|
|
+ WSSSimpleLog("reader audio completed")
|
|
}
|
|
}
|
|
self.lock.unlock()
|
|
self.lock.unlock()
|
|
return buffer
|
|
return buffer
|
|
@@ -111,7 +111,7 @@ class OJAAssetReader: NSObject {
|
|
let buffer: CMSampleBuffer? = videoTrackOutput?.copyNextSampleBuffer()
|
|
let buffer: CMSampleBuffer? = videoTrackOutput?.copyNextSampleBuffer()
|
|
self.lock.unlock()
|
|
self.lock.unlock()
|
|
if let reader = assetReader, reader.status == .completed {
|
|
if let reader = assetReader, reader.status == .completed {
|
|
- NSLog("reader video completed")
|
|
|
|
|
|
+ WSSSimpleLog("reader video completed")
|
|
if self.shouldRepeat {
|
|
if self.shouldRepeat {
|
|
self.reset() //按理说如果视频不够长,则需要循环播放
|
|
self.reset() //按理说如果视频不够长,则需要循环播放
|
|
}
|
|
}
|