Commit 3f786966 authored by lmj_521aiau@163.com's avatar lmj_521aiau@163.com

no message

parent fd240c61
...@@ -26,9 +26,9 @@ class SHRecordModel: NSObject{ ...@@ -26,9 +26,9 @@ class SHRecordModel: NSObject{
//录音时间 估算 //录音时间 估算
@objc var during: NSInteger = 0 @objc var during: NSInteger = 0
//照片资源 //照片资源
@objc var images: [String] = [] // @objc var images: [UIImage] = []
@objc var imagesPath: [String] = [] @objc var imagesPath: [String] = []
@objc var imagesIndex: [String] = [] @objc var imagesIndex: [NSInteger] = []
@objc var selected: Bool = false @objc var selected: Bool = false
@objc var icloud: Bool = false @objc var icloud: Bool = false
......
...@@ -48,7 +48,10 @@ class SHRecordViewController: SHBaseViewController{ ...@@ -48,7 +48,10 @@ class SHRecordViewController: SHBaseViewController{
var wav_file_path = DocumentPath.appending("/record.wav") var wav_file_path = DocumentPath.appending("/record.wav")
var mp3_file_path = DocumentPath.appending("/record.mp3") var mp3_file_path = DocumentPath.appending("/record.mp3")
var pcm_file_path = DocumentPath.appending("/xbMixData.caf") var pcm_file_path = DocumentPath.appending("/xbMixData.caf")
var images_file_path:[String] = []
var image_file_path = ""
var image_file_paths: [String] = []
var image_indexs: [NSInteger] = []
var session:AVAudioSession { var session:AVAudioSession {
let session:AVAudioSession = AVAudioSession.sharedInstance() let session:AVAudioSession = AVAudioSession.sharedInstance()
...@@ -333,6 +336,7 @@ class SHRecordViewController: SHBaseViewController{ ...@@ -333,6 +336,7 @@ class SHRecordViewController: SHBaseViewController{
let subFile = Date().format("yyyyMMdd") let subFile = Date().format("yyyyMMdd")
var exist = false var exist = false
let time = Date.init().timeStamp let time = Date.init().timeStamp
for (_, documentsFile) in fileArr!.enumerated() { for (_, documentsFile) in fileArr!.enumerated() {
if documentsFile == DocumentPath.appending("/\(subFile)") { if documentsFile == DocumentPath.appending("/\(subFile)") {
...@@ -341,6 +345,8 @@ class SHRecordViewController: SHBaseViewController{ ...@@ -341,6 +345,8 @@ class SHRecordViewController: SHBaseViewController{
mp3_file_path = "/"+subFile+time+"/record.mp3" mp3_file_path = "/"+subFile+time+"/record.mp3"
pcm_file_path = "/"+subFile+time+"/xbMixData.caf" pcm_file_path = "/"+subFile+time+"/xbMixData.caf"
image_file_path = "/"+subFile+time+"/"
try! fileManager.createDirectory(atPath: path, withIntermediateDirectories: true, attributes: nil) try! fileManager.createDirectory(atPath: path, withIntermediateDirectories: true, attributes: nil)
recorder_mp3.configMp3Path(DocumentPath+mp3_file_path, pcmPath: DocumentPath+pcm_file_path) recorder_mp3.configMp3Path(DocumentPath+mp3_file_path, pcmPath: DocumentPath+pcm_file_path)
...@@ -355,6 +361,8 @@ class SHRecordViewController: SHBaseViewController{ ...@@ -355,6 +361,8 @@ class SHRecordViewController: SHBaseViewController{
mp3_file_path = "/"+subFile+time+"/record.mp3" mp3_file_path = "/"+subFile+time+"/record.mp3"
pcm_file_path = "/"+subFile+time+"/xbMixData.caf" pcm_file_path = "/"+subFile+time+"/xbMixData.caf"
image_file_path = "/"+subFile+time+"/"
try! fileManager.createDirectory(atPath: path, withIntermediateDirectories: true, attributes: nil) try! fileManager.createDirectory(atPath: path, withIntermediateDirectories: true, attributes: nil)
recorder_mp3.configMp3Path(DocumentPath+mp3_file_path, pcmPath: DocumentPath+pcm_file_path) recorder_mp3.configMp3Path(DocumentPath+mp3_file_path, pcmPath: DocumentPath+pcm_file_path)
...@@ -489,6 +497,20 @@ class SHRecordViewController: SHBaseViewController{ ...@@ -489,6 +497,20 @@ class SHRecordViewController: SHBaseViewController{
model.pcmPathFile = pcm_file_path model.pcmPathFile = pcm_file_path
model.during = seconds model.during = seconds
image_file_paths = []
image_indexs = []
let images = ["recordlist_no_data_search", "recordlist_no_data"]
for (index, imageStr) in images.enumerated(){
let image = UIImage.init(named: imageStr)
let filePath = DocumentPath+image_file_path+"\(index).jpeg"
let imageData = image!.jpegData(compressionQuality: 1)
try? imageData?.write(to: URL(fileURLWithPath: filePath))
image_file_paths.append(image_file_path+"\(index).jpeg")
image_indexs.append(index)
}
model.imagesPath = image_file_paths
model.imagesIndex = image_indexs
var contains = false var contains = false
if folderModel.dataSources.count != 0 { if folderModel.dataSources.count != 0 {
......
...@@ -142,6 +142,28 @@ class SHCloudManager: NSObject { ...@@ -142,6 +142,28 @@ class SHCloudManager: NSObject {
let asset = record["recordAsset"] as! CKAsset let asset = record["recordAsset"] as! CKAsset
recordModel.assetFileUrlPath = asset.fileURL?.path ?? "" recordModel.assetFileUrlPath = asset.fileURL?.path ?? ""
recordModel.imagesIndex = record["imagesIndex"] as? Array<NSInteger> ?? []
recordModel.imagesPath = record["imagesPath"] as? Array<String> ?? []
let assets = record["imagesAsset"] as? [CKAsset] ?? []
for (index, asset) in assets.enumerated(){
if index > recordModel.imagesIndex.count-1 {
break
}
if index > recordModel.imagesPath.count-1 {
break
}
var path = recordModel.imagesPath[index]
path = DocumentPath+path
// if let image = UIImage.init(contentsOfFile: asset.fileURL!.path){
// recordModel.images.append(image)
// }
if FileManager.default.fileExists(atPath: path) == false {
if let imageData = try? Data(contentsOf: asset.fileURL!){
try! FileManager.default.createDirectory(atPath: path, withIntermediateDirectories: true, attributes: nil)
try? imageData.write(to: URL(fileURLWithPath: path))
}
}
}
folderModel.dataSources.append(recordModel) folderModel.dataSources.append(recordModel)
} }
} }
...@@ -210,9 +232,16 @@ class SHCloudManager: NSObject { ...@@ -210,9 +232,16 @@ class SHCloudManager: NSObject {
record.setValue(nowDate, forKey: "modifyDate") record.setValue(nowDate, forKey: "modifyDate")
record.setValue(asset, forKey: "recordAsset") record.setValue(asset, forKey: "recordAsset")
for image in recordModel.images { record.setValue(recordModel.imagesIndex, forKey: "imagesIndex")
record.setValue(recordModel.imagesPath, forKey: "imagesPath")
var imageAssets:[CKAsset] = []
for path in recordModel.imagesPath {
let imageFile = DocumentPath.appending(path)
let url = URL.init(fileURLWithPath: imageFile)
let asset = CKAsset.init(fileURL: url)
imageAssets.append(asset)
} }
record.setValue(imageAssets, forKey: "imagesAsset")
dateBase.save(record) { (subscription, saveError) in dateBase.save(record) { (subscription, saveError) in
if let error = saveError { if let error = saveError {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment