Repository Public MIT
1{2 "accessibility" : [3 "Every button has a label (\"Play\", \"Pause\", \"Skip back\", \"Skip forward\") and a tooltip on macOS; hit targets are at least 44 points on iOS.",4 "The slider is labelled \"Playback position\" and its value is spoken as \"1:05 of 3:20\"; it is adjustable with the standard VoiceOver gestures.",5 "Elapsed and remaining times are labelled; they use monospaced digits and Dynamic Type.",6 "Space toggles play and pause with a hardware keyboard.",7 "With Reduce Transparency the surface becomes opaque (handled by `glassSurface`)."8 ],9 "category" : "media",10 "changelog" : [11 {12 "changes" : [13 "Release 1.1.0: see the project changelog."14 ],15 "date" : "2026-12-03",16 "version" : "1.1.0"17 },18 {19 "changes" : [20 "Initial release."21 ],22 "date" : "2026-12-02",23 "version" : "1.0.0"24 }25 ],26 "dependencies" : [27 {28 "id" : "glass-foundation",29 "version" : "1.1.0"30 },31 {32 "id" : "glass-media-support",33 "version" : "1.1.0"34 },35 {36 "id" : "glass-waveform",37 "version" : "1.1.0"38 }39 ],40 "description" : "Audio transport with play, pause, seek, times and interruption handling; never starts by itself.",41 "examples" : [42 {43 "code" : "import SwiftUI\nimport SPGlassKit\n\n/// A silent playback engine for the example: it only moves a clock, no audio is produced.\n@MainActor\n@Observable\nfinal class SampleAudioPlayback: GlassAudioPlayback {\n private(set) var isPlaying = false\n private(set) var currentTime: TimeInterval = 42\n let duration: TimeInterval\n let isAvailable: Bool\n\n init(duration: TimeInterval = 215, isAvailable: Bool = true) {\n self.duration = duration\n self.isAvailable = isAvailable\n }\n\n func play() {\n guard isAvailable else { return }\n if currentTime >= duration { currentTime = 0 }\n isPlaying = true\n }\n\n func pause() { isPlaying = false }\n\n func seek(to time: TimeInterval) {\n currentTime = GlassPlaybackMath.clampedSeek(time, duration: duration)\n }\n\n /// Advances the simulated clock; called by the example while \"playing\".\n func advance(by seconds: TimeInterval) {\n currentTime = GlassPlaybackMath.clampedSeek(currentTime + seconds, duration: duration)\n if currentTime >= duration { isPlaying = false }\n }\n}\n\npublic struct GlassAudioPlayerExample: GlassExample {\n public static let componentID = \"glass-audio-player\"\n @State private var playback = SampleAudioPlayback()\n @State private var unavailable = SampleAudioPlayback(duration: 0, isAvailable: false)\n\n /// Amplitudes of a fictitious recording, aggregated once.\n private static let waveform = GlassWaveformData(samples: GlassWaveformExample.syntheticSamples(count: 9_600), maxBuckets: 64)\n\n public init() {}\n\n public var body: some View {\n VStack(spacing: 16) {\n GlassAudioPlayer(playback: playback, title: \"Harbour Lines\", subtitle: \"Sample data · simulated clock, no audio\", artwork: SampleArtwork.image(1))\n GlassAudioPlayer(playback: playback, title: \"Harbour Lines\", subtitle: \"With a waveform as the seek track\", skipInterval: 30, waveform: Self.waveform)\n GlassAudioPlayer(playback: playback, title: \"Harbour Lines\", subtitle: \"Compact\", artwork: SampleArtwork.image(1), style: .compact)\n GlassAudioPlayer(playback: unavailable, title: \"Missing recording\", skipInterval: 30)\n }\n .padding()\n .task(id: playback.isPlaying) {\n // The fake engine has no audio clock: tick it while it is \"playing\".\n while playback.isPlaying, !Task.isCancelled {\n try? await Task.sleep(for: .milliseconds(500))\n if !Task.isCancelled { playback.advance(by: 0.5) }\n }\n }\n }\n}\n\n#Preview(\"GlassAudioPlayer\") { GlassAudioPlayerExample().glassTheme(.ocean) }\n",44 "title" : "GlassAudioPlayer example"45 }46 ],47 "files" : [48 {49 "bytes" : 14378,50 "path" : "Media/Media/GlassAudioPlayer.swift",51 "sha256" : "803e3f2757fa1e813bc5f3065e5d8b41716342d5c6579a2da1d257ff4b401260"52 }53 ],54 "frameworks" : [55 "AVFoundation"56 ],57 "id" : "glass-audio-player",58 "kind" : "custom-glass",59 "license" : "MIT",60 "minimumOS" : {61 "iOS" : "26.0",62 "iPadOS" : "26.0",63 "macOS" : "26.0"64 },65 "name" : "GlassAudioPlayer",66 "platforms" : [67 "iOS",68 "iPadOS",69 "macOS"70 ],71 "schemaVersion" : 1,72 "sha256" : "0438c7ec628d26aa661a2db9868da2599d1b06070a8bf4e0bf61cdacf79bd8fe",73 "symbols" : [74 "GlassAudioPlayerStyle",75 "GlassAudioPlayer",76 "GlassAudioPlayerSymbols"77 ],78 "version" : "1.1.0"79}80