Merge iOS and Mac app into one
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import SwiftUI
|
||||
#if os(iOS)
|
||||
import AVFAudio
|
||||
#endif
|
||||
|
||||
@main
|
||||
struct Audiobookshelf_swiftApp: App {
|
||||
@State private var appState = AppState()
|
||||
|
||||
init() {
|
||||
#if os(iOS)
|
||||
configureAudioSession()
|
||||
#endif
|
||||
}
|
||||
|
||||
var body: some Scene {
|
||||
#if os(macOS)
|
||||
WindowGroup {
|
||||
ContentView()
|
||||
.environment(appState)
|
||||
}
|
||||
.windowResizability(.contentSize)
|
||||
|
||||
Settings {
|
||||
SettingsView()
|
||||
.environment(appState)
|
||||
}
|
||||
#else
|
||||
WindowGroup {
|
||||
ContentView()
|
||||
.environment(appState)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
private func configureAudioSession() {
|
||||
do {
|
||||
let session = AVAudioSession.sharedInstance()
|
||||
try session.setCategory(.playback, mode: .default, options: [])
|
||||
try session.setActive(true)
|
||||
} catch {
|
||||
// non-fatal
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user