Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
ShorthandMaster
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lmj
ShorthandMaster
Commits
a4ee7562
Commit
a4ee7562
authored
Sep 27, 2020
by
zhangzhe
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'branch_1.0.1' of gitlab.huolea.com:lmi/shorthandmaster into branch_1.0.1
parents
15d02a8a
1a421bdd
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
22 deletions
+66
-22
SHRecordModel.swift
ShorthandMaster/Record/Model/SHRecordModel.swift
+2
-2
SHRecordShowViewController.swift
ShorthandMaster/Record/SHRecordShowViewController.swift
+6
-14
SHRecordViewController.swift
ShorthandMaster/Record/SHRecordViewController.swift
+24
-2
SHCloudManager.swift
ShorthandMaster/Share/Managers/SHCloudManager.swift
+34
-4
No files found.
ShorthandMaster/Record/Model/SHRecordModel.swift
View file @
a4ee7562
...
...
@@ -26,9 +26,9 @@ class SHRecordModel: NSObject{
//录音时间 估算
@objc
var
during
:
NSInteger
=
0
//照片资源
@objc
var
images
:
[
String
]
=
[]
// @objc var images: [UIImage
] = []
@objc
var
imagesPath
:
[
String
]
=
[]
@objc
var
imagesIndex
:
[
String
]
=
[]
@objc
var
imagesIndex
:
[
NSInteger
]
=
[]
@objc
var
selected
:
Bool
=
false
@objc
var
icloud
:
Bool
=
false
...
...
ShorthandMaster/Record/SHRecordShowViewController.swift
View file @
a4ee7562
...
...
@@ -52,20 +52,12 @@ class SHRecordShowViewController: SHBaseViewController {
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
// AVAudioSession.sharedInstance().requestRecordPermission { (allowed) in
// if !allowed {
// return
// }
// }
// let session:AVAudioSession = AVAudioSession.sharedInstance()
// do {
// try session.setCategory(AVAudioSession.Category.playAndRecord, options: .defaultToSpeaker)
// }catch{
// print("session config failed")
// }
//
// do { try AVAudioSession.sharedInstance().setActive(true) }
// catch { print("session active failed") }
for
path
in
model
!.
imagesPath
{
let
s
=
DocumentPath
+
path
if
let
image
=
UIImage
.
init
(
contentsOfFile
:
s
){
}
}
setupUI
()
play
()
...
...
ShorthandMaster/Record/SHRecordViewController.swift
View file @
a4ee7562
...
...
@@ -48,7 +48,10 @@ class SHRecordViewController: SHBaseViewController{
var
wav_file_path
=
DocumentPath
.
appending
(
"/record.wav"
)
var
mp3_file_path
=
DocumentPath
.
appending
(
"/record.mp3"
)
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
{
let
session
:
AVAudioSession
=
AVAudioSession
.
sharedInstance
()
...
...
@@ -333,6 +336,7 @@ class SHRecordViewController: SHBaseViewController{
let
subFile
=
Date
()
.
format
(
"yyyyMMdd"
)
var
exist
=
false
let
time
=
Date
.
init
()
.
timeStamp
for
(
_
,
documentsFile
)
in
fileArr
!.
enumerated
()
{
if
documentsFile
==
DocumentPath
.
appending
(
"/
\(
subFile
)
"
)
{
...
...
@@ -341,6 +345,8 @@ class SHRecordViewController: SHBaseViewController{
mp3_file_path
=
"/"
+
subFile
+
time
+
"/record.mp3"
pcm_file_path
=
"/"
+
subFile
+
time
+
"/xbMixData.caf"
image_file_path
=
"/"
+
subFile
+
time
+
"/"
try!
fileManager
.
createDirectory
(
atPath
:
path
,
withIntermediateDirectories
:
true
,
attributes
:
nil
)
recorder_mp3
.
configMp3Path
(
DocumentPath
+
mp3_file_path
,
pcmPath
:
DocumentPath
+
pcm_file_path
)
...
...
@@ -355,6 +361,8 @@ class SHRecordViewController: SHBaseViewController{
mp3_file_path
=
"/"
+
subFile
+
time
+
"/record.mp3"
pcm_file_path
=
"/"
+
subFile
+
time
+
"/xbMixData.caf"
image_file_path
=
"/"
+
subFile
+
time
+
"/"
try!
fileManager
.
createDirectory
(
atPath
:
path
,
withIntermediateDirectories
:
true
,
attributes
:
nil
)
recorder_mp3
.
configMp3Path
(
DocumentPath
+
mp3_file_path
,
pcmPath
:
DocumentPath
+
pcm_file_path
)
...
...
@@ -489,6 +497,20 @@ class SHRecordViewController: SHBaseViewController{
model
.
pcmPathFile
=
pcm_file_path
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
if
folderModel
.
dataSources
.
count
!=
0
{
...
...
ShorthandMaster/Share/Managers/SHCloudManager.swift
View file @
a4ee7562
...
...
@@ -142,6 +142,29 @@ class SHCloudManager: NSObject {
let
asset
=
record
[
"recordAsset"
]
as!
CKAsset
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
}
let
path
=
recordModel
.
imagesPath
[
index
]
var
filePath
=
path
.
components
(
separatedBy
:
"/"
)[
1
]
filePath
=
DocumentPath
+
"/"
+
filePath
// if let image = UIImage.init(contentsOfFile: asset.fileURL!.path){
// recordModel.images.append(image)
// }
if
FileManager
.
default
.
fileExists
(
atPath
:
filePath
)
==
false
{
if
let
imageData
=
try
?
Data
(
contentsOf
:
asset
.
fileURL
!
){
try!
FileManager
.
default
.
createDirectory
(
atPath
:
filePath
,
withIntermediateDirectories
:
true
,
attributes
:
nil
)
try
?
imageData
.
write
(
to
:
URL
(
fileURLWithPath
:
DocumentPath
+
path
))
}
}
}
folderModel
.
dataSources
.
append
(
recordModel
)
}
}
...
...
@@ -210,9 +233,16 @@ class SHCloudManager: NSObject {
record
.
setValue
(
nowDate
,
forKey
:
"modifyDate"
)
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
if
let
error
=
saveError
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment