Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
b59fe7fe26
commit
6fd0562a41
@ -6,7 +6,8 @@ import PackageDescription
|
||||
let package = Package(
|
||||
name: "AudioPlaybackKit",
|
||||
platforms: [
|
||||
.iOS(.v17)
|
||||
.iOS(.v17),
|
||||
.tvOS(.v17)
|
||||
],
|
||||
products: [
|
||||
// Products define the executables and libraries a package produces, making them visible to other packages.
|
||||
|
||||
@ -9,7 +9,7 @@ import AVFoundation
|
||||
import Observation
|
||||
|
||||
/// Audio playback service for white noise and ambient sounds
|
||||
@available(iOS 17.0, *)
|
||||
@available(iOS 17.0, tvOS 17.0, *)
|
||||
@Observable
|
||||
public class NoisePlayer {
|
||||
|
||||
|
||||
@ -5,11 +5,13 @@
|
||||
// Created by Matt Bruce on 9/8/25.
|
||||
//
|
||||
|
||||
#if canImport(UIKit)
|
||||
import UIKit
|
||||
#endif
|
||||
import Observation
|
||||
|
||||
/// Service to manage screen wake lock and prevent device from sleeping
|
||||
@available(iOS 17.0, *)
|
||||
@available(iOS 17.0, tvOS 17.0, *)
|
||||
@Observable
|
||||
public class WakeLockService {
|
||||
|
||||
@ -33,6 +35,7 @@ public class WakeLockService {
|
||||
public func enableWakeLock() {
|
||||
guard !isWakeLockActive else { return }
|
||||
|
||||
#if canImport(UIKit)
|
||||
// Prevent device from sleeping
|
||||
UIApplication.shared.isIdleTimerDisabled = true
|
||||
|
||||
@ -44,6 +47,7 @@ public class WakeLockService {
|
||||
UIApplication.shared.isIdleTimerDisabled = true
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
isWakeLockActive = true
|
||||
print("🔒 Wake lock enabled - device will not sleep")
|
||||
@ -53,8 +57,10 @@ public class WakeLockService {
|
||||
public func disableWakeLock() {
|
||||
guard isWakeLockActive else { return }
|
||||
|
||||
#if canImport(UIKit)
|
||||
// Allow device to sleep normally
|
||||
UIApplication.shared.isIdleTimerDisabled = false
|
||||
#endif
|
||||
|
||||
// Stop the maintenance timer
|
||||
wakeLockTimer?.invalidate()
|
||||
|
||||
@ -9,7 +9,7 @@ import Foundation
|
||||
import Observation
|
||||
|
||||
/// ViewModel for noise/audio playback
|
||||
@available(iOS 17.0, *)
|
||||
@available(iOS 17.0, tvOS 17.0, *)
|
||||
@Observable
|
||||
public class NoiseViewModel {
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user