Stabilize iOS/watchOS/tvOS apps and add cross-platform audit remediation
This commit is contained in:
@@ -7,10 +7,12 @@
|
||||
|
||||
import AVKit
|
||||
import AVFoundation
|
||||
import SharedCore
|
||||
|
||||
class AudioEngine {
|
||||
static let shared = AudioEngine()
|
||||
private init() { }
|
||||
private let runtimeReporter = RuntimeReporter.shared
|
||||
|
||||
var audioPlayer: AVAudioPlayer?
|
||||
var avPlayer: AVPlayer?
|
||||
@@ -24,10 +26,11 @@ class AudioEngine {
|
||||
options: [.mixWithOthers])
|
||||
try AVAudioSession.sharedInstance().setActive(true)
|
||||
|
||||
avPlayer?.pause()
|
||||
avPlayer = AVPlayer(playerItem: playerItem)
|
||||
avPlayer?.play()
|
||||
} catch {
|
||||
print("ERROR")
|
||||
runtimeReporter.recordError("Failed playing remote audio", metadata: ["error": error.localizedDescription])
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -41,10 +44,11 @@ class AudioEngine {
|
||||
options: [.mixWithOthers])
|
||||
try AVAudioSession.sharedInstance().setActive(true)
|
||||
|
||||
audioPlayer?.stop()
|
||||
audioPlayer = try AVAudioPlayer(contentsOf: URL(fileURLWithPath: path))
|
||||
audioPlayer?.play()
|
||||
} catch {
|
||||
print("ERROR")
|
||||
runtimeReporter.recordError("Failed playing short beep", metadata: ["error": error.localizedDescription])
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -59,10 +63,11 @@ class AudioEngine {
|
||||
options: [.mixWithOthers])
|
||||
try AVAudioSession.sharedInstance().setActive(true)
|
||||
|
||||
audioPlayer?.stop()
|
||||
audioPlayer = try AVAudioPlayer(contentsOf: URL(fileURLWithPath: path))
|
||||
audioPlayer?.play()
|
||||
} catch {
|
||||
print("ERROR")
|
||||
runtimeReporter.recordError("Failed playing long beep", metadata: ["error": error.localizedDescription])
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user