split files up, fix complete workout screen not showing if remove workout details screen
This commit is contained in:
66
iphone/Werkout_ios/AudioEngine.swift
Normal file
66
iphone/Werkout_ios/AudioEngine.swift
Normal file
@@ -0,0 +1,66 @@
|
||||
//
|
||||
// AudioEngine.swift
|
||||
// Werkout_ios
|
||||
//
|
||||
// Created by Trey Tartt on 6/21/24.
|
||||
//
|
||||
|
||||
import AVKit
|
||||
|
||||
class AudioEngine {
|
||||
// var audioPlayer: AVAudioPlayer?
|
||||
// var avPlayer: AVPlayer?
|
||||
|
||||
static func playRemoteAudio(fromURL url: URL) {
|
||||
#if os(iOS)
|
||||
let playerItem = AVPlayerItem(url: url)
|
||||
do {
|
||||
try AVAudioSession.sharedInstance().setCategory(.playback,
|
||||
mode: .default,
|
||||
options: [.mixWithOthers])
|
||||
try AVAudioSession.sharedInstance().setActive(true)
|
||||
|
||||
let avPlayer = AVPlayer(playerItem: playerItem)
|
||||
avPlayer.play()
|
||||
} catch {
|
||||
print("ERROR")
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static func playBeep() {
|
||||
#if os(iOS)
|
||||
if let path = Bundle.main.path(forResource: "short_beep", ofType: "m4a") {
|
||||
do {
|
||||
try AVAudioSession.sharedInstance().setCategory(.playback,
|
||||
mode: .default,
|
||||
options: [.mixWithOthers])
|
||||
try AVAudioSession.sharedInstance().setActive(true)
|
||||
|
||||
let audioPlayer = try AVAudioPlayer(contentsOf: URL(fileURLWithPath: path))
|
||||
audioPlayer.play()
|
||||
} catch {
|
||||
print("ERROR")
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static func playFinished() {
|
||||
#if os(iOS)
|
||||
if let path = Bundle.main.path(forResource: "long_beep", ofType: "m4a") {
|
||||
do {
|
||||
try AVAudioSession.sharedInstance().setCategory(.playback,
|
||||
mode: .default,
|
||||
options: [.mixWithOthers])
|
||||
try AVAudioSession.sharedInstance().setActive(true)
|
||||
|
||||
let audioPlayer = try AVAudioPlayer(contentsOf: URL(fileURLWithPath: path))
|
||||
audioPlayer.play()
|
||||
} catch {
|
||||
print("ERROR")
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user