Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
xx messenger iOS
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile
iOS
xx messenger iOS
Commits
33b3a86f
Commit
33b3a86f
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Handle AVAudioPlayer setup failure in Voxophone
parent
96acd34c
No related branches found
No related tags found
1 merge request
!110
Fix crash with dictation and audio recording
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Sources/Voxophone/Voxophone.swift
+8
-4
8 additions, 4 deletions
Sources/Voxophone/Voxophone.swift
with
8 additions
and
4 deletions
Sources/Voxophone/Voxophone.swift
+
8
−
4
View file @
33b3a86f
...
@@ -41,8 +41,12 @@ public final class Voxophone: NSObject, AVAudioRecorderDelegate, AVAudioPlayerDe
...
@@ -41,8 +41,12 @@ public final class Voxophone: NSObject, AVAudioRecorderDelegate, AVAudioPlayerDe
public
func
load
(
_
url
:
URL
)
{
public
func
load
(
_
url
:
URL
)
{
destroyPlayer
()
destroyPlayer
()
destroyRecorder
()
destroyRecorder
()
let
player
=
setupPlayer
(
url
:
url
)
do
{
state
=
.
idle
(
url
,
duration
:
player
.
duration
,
isLoudspeaker
:
state
.
isLoudspeaker
)
let
player
=
try
setupPlayer
(
url
:
url
)
state
=
.
idle
(
url
,
duration
:
player
.
duration
,
isLoudspeaker
:
state
.
isLoudspeaker
)
}
catch
{
state
=
.
empty
(
isLoudspeaker
:
state
.
isLoudspeaker
)
}
}
}
public
func
play
()
{
public
func
play
()
{
...
@@ -76,8 +80,8 @@ public final class Voxophone: NSObject, AVAudioRecorderDelegate, AVAudioPlayerDe
...
@@ -76,8 +80,8 @@ public final class Voxophone: NSObject, AVAudioRecorderDelegate, AVAudioPlayerDe
}
}
}
}
private
func
setupPlayer
(
url
:
URL
)
->
AVAudioPlayer
{
private
func
setupPlayer
(
url
:
URL
)
throws
->
AVAudioPlayer
{
let
player
=
try
!
AVAudioPlayer
(
contentsOf
:
url
,
fileTypeHint
:
AVFileType
.
m4a
.
rawValue
)
let
player
=
try
AVAudioPlayer
(
contentsOf
:
url
,
fileTypeHint
:
AVFileType
.
m4a
.
rawValue
)
self
.
player
=
player
self
.
player
=
player
return
player
return
player
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment