Skip to content

Commit dafff95

Browse files
committed
SwiftFormat code
1 parent 5630679 commit dafff95

19 files changed

+120
-86
lines changed

Examples/SwiftAudioKitExample/SwiftAudioKitExample/AudioPlayerManager.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import AVFoundation
44
import SwiftAudioKit
55

66
class AudioPlayerManager: ObservableObject {
7-
@Published var currentTrackTitle: String = "No Track"
8-
@Published var isPlaying: Bool = false
7+
@Published
8+
var currentTrackTitle: String = "No Track"
9+
@Published
10+
var isPlaying: Bool = false
911

1012
private var audioPlayer: AudioPlayer
1113

Examples/SwiftAudioKitExample/SwiftAudioKitExample/AudioPlayerView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import SwiftUI
22

33
struct AudioPlayerView: View {
4-
@StateObject private var audioPlayerManager = AudioPlayerManager()
4+
@StateObject
5+
private var audioPlayerManager = AudioPlayerManager()
56

67
var body: some View {
78
VStack {

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ let package = Package(
1717
name: "SwiftAudioKit",
1818
targets: ["SwiftAudioKit"]
1919
),
20-
],
20+
],
2121
dependencies: [
2222
// Package dependencies
2323
],

Sources/SwiftAudioKit/Event/NetworkEventProducer.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// Copyright © 2024 Dionysios Karatzas. All rights reserved.
66
//
77

8-
import Foundation
98
import Combine
109
import Foundation
1110

Sources/SwiftAudioKit/Event/QualityAdjustmentEventProducer.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// Copyright © 2024 Dionysios Karatzas. All rights reserved.
66
//
77

8-
import Foundation
98
import Combine
109
import Foundation
1110

Sources/SwiftAudioKit/Item/AudioItem.swift

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,21 @@ open class AudioItem: ObservableObject {
102102

103103
/// Returns the highest quality URL found, or nil if no URLs are available.
104104
open var highestQualityURL: AudioItemURL {
105-
return AudioItemURL(quality: .high, url: soundURLs[.high]) ??
105+
AudioItemURL(quality: .high, url: soundURLs[.high]) ??
106106
AudioItemURL(quality: .medium, url: soundURLs[.medium]) ??
107107
AudioItemURL(quality: .low, url: soundURLs[.low])!
108108
}
109109

110110
/// Returns the medium quality URL found, or nil if no URLs are available.
111111
open var mediumQualityURL: AudioItemURL {
112-
return AudioItemURL(quality: .medium, url: soundURLs[.medium]) ??
112+
AudioItemURL(quality: .medium, url: soundURLs[.medium]) ??
113113
AudioItemURL(quality: .low, url: soundURLs[.low]) ??
114114
AudioItemURL(quality: .high, url: soundURLs[.high])!
115115
}
116116

117117
/// Returns the lowest quality URL found, or nil if no URLs are available.
118118
open var lowestQualityURL: AudioItemURL {
119-
return AudioItemURL(quality: .low, url: soundURLs[.low]) ??
119+
AudioItemURL(quality: .low, url: soundURLs[.low]) ??
120120
AudioItemURL(quality: .medium, url: soundURLs[.medium]) ??
121121
AudioItemURL(quality: .high, url: soundURLs[.high])!
122122
}
@@ -128,35 +128,40 @@ open class AudioItem: ObservableObject {
128128
func url(for quality: AudioQuality) -> AudioItemURL {
129129
switch quality {
130130
case .high:
131-
return highestQualityURL
131+
highestQualityURL
132132
case .medium:
133-
return mediumQualityURL
133+
mediumQualityURL
134134
default:
135-
return lowestQualityURL
135+
lowestQualityURL
136136
}
137137
}
138138

139139
// MARK: Additional properties
140140

141141
/// The artist of the item.
142-
@Published open var artist: String?
142+
@Published
143+
open var artist: String?
143144

144145
/// The title of the item.
145-
@Published open var title: String?
146+
@Published
147+
open var title: String?
146148

147149
/// The album of the item.
148-
@Published open var album: String?
150+
@Published
151+
open var album: String?
149152

150153
/// The track count of the item's album.
151-
@Published open var trackCount: NSNumber?
154+
@Published
155+
open var trackCount: NSNumber?
152156

153157
/// The track number of the item in its album.
154-
@Published open var trackNumber: NSNumber?
158+
@Published
159+
open var trackNumber: NSNumber?
155160

156161
/// The artwork image of the item.
157162
open var artworkImage: SystemImage? {
158163
get {
159-
return artwork?.image(at: imageSize ?? CGSize(width: 512, height: 512))
164+
artwork?.image(at: imageSize ?? CGSize(width: 512, height: 512))
160165
}
161166
set {
162167
imageSize = newValue?.size
@@ -168,7 +173,8 @@ open class AudioItem: ObservableObject {
168173
}
169174
}
170175

171-
@Published open var artwork: MPMediaItemArtwork?
176+
@Published
177+
open var artwork: MPMediaItemArtwork?
172178
private var imageSize: CGSize?
173179

174180
// MARK: Metadata
@@ -201,6 +207,6 @@ open class AudioItem: ObservableObject {
201207

202208
extension AudioItem: Equatable {
203209
public static func == (lhs: AudioItem, rhs: AudioItem) -> Bool {
204-
return lhs === rhs
210+
lhs === rhs
205211
}
206212
}

Sources/SwiftAudioKit/Item/AudioItemQueue.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,6 @@ class AudioItemQueue {
226226
/// - Parameter item: The item to check.
227227
/// - Returns: A boolean value indicating whether the item should be considered playable.
228228
private func shouldConsiderItem(item: AudioItem) -> Bool {
229-
return delegate?.audioItemQueue(self, shouldConsiderItem: item) ?? true
229+
delegate?.audioItemQueue(self, shouldConsiderItem: item) ?? true
230230
}
231231
}

Sources/SwiftAudioKit/NowPlayable/NowPlayableError.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ public enum NowPlayableError: LocalizedError {
1616
public var errorDescription: String? {
1717
switch self {
1818
case .noRegisteredCommands:
19-
return "At least one remote command must be registered."
19+
"At least one remote command must be registered."
2020

2121
case let .cannotSetCategory(error):
22-
return "The audio session category could not be set:\n\(error)"
22+
"The audio session category could not be set:\n\(error)"
2323

2424
case let .cannotActivateSession(error):
25-
return "The audio session could not be activated:\n\(error)"
25+
"The audio session could not be activated:\n\(error)"
2626

2727
case let .cannotReactivateSession(error):
28-
return "The audio session could not be resumed after interruption:\n\(error)"
28+
"The audio session could not be resumed after interruption:\n\(error)"
2929
}
3030
}
3131
}

Sources/SwiftAudioKit/NowPlayable/NowPlayableMetadata.swift

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,17 @@ public struct NowPlayableStaticMetadata {
1919
public let trackCount: NSNumber? // MPMediaItemPropertyAlbumTrackCount
2020
public let trackNumber: NSNumber? // MPMediaItemPropertyAlbumTrackNumber
2121

22-
public init(assetURL: URL, mediaType: MPNowPlayingInfoMediaType, isLiveStream: Bool, title: String?, artist: String?, artwork: MPMediaItemArtwork?, album: String?, trackCount: NSNumber?, trackNumber: NSNumber?) {
22+
public init(
23+
assetURL: URL,
24+
mediaType: MPNowPlayingInfoMediaType,
25+
isLiveStream: Bool,
26+
title: String?,
27+
artist: String?,
28+
artwork: MPMediaItemArtwork?,
29+
album: String?,
30+
trackCount: NSNumber?,
31+
trackNumber: NSNumber?
32+
) {
2333
self.assetURL = assetURL
2434
self.mediaType = mediaType
2535
self.isLiveStream = isLiveStream
@@ -39,7 +49,13 @@ public struct NowPlayableDynamicMetadata {
3949
public let currentLanguageOptions: [MPNowPlayingInfoLanguageOption] // MPNowPlayingInfoPropertyCurrentLanguageOptions
4050
public let availableLanguageOptionGroups: [MPNowPlayingInfoLanguageOptionGroup] // MPNowPlayingInfoPropertyAvailableLanguageOptions
4151

42-
public init(rate: Float, position: Float, duration: Float, currentLanguageOptions: [MPNowPlayingInfoLanguageOption], availableLanguageOptionGroups: [MPNowPlayingInfoLanguageOptionGroup]) {
52+
public init(
53+
rate: Float,
54+
position: Float,
55+
duration: Float,
56+
currentLanguageOptions: [MPNowPlayingInfoLanguageOption],
57+
availableLanguageOptionGroups: [MPNowPlayingInfoLanguageOptionGroup]
58+
) {
4359
self.rate = rate
4460
self.position = position
4561
self.duration = duration

Sources/SwiftAudioKit/NowPlayable/NowPlayableService.swift

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,14 @@ public extension NowPlayableService {
4747
// Customization point: start a `NowPlayable` session, either by activating an audio session
4848
// or setting a playback state, depending on platform.
4949
func handleNowPlayableSessionStart() throws {
50-
#if os(macOS)
51-
MPNowPlayingInfoCenter.default().playbackState = .paused
52-
#endif
50+
MPNowPlayingInfoCenter.default().playbackState = .paused
5351
}
5452

5553
// Customization point: end a `NowPlayable` session, to allow other apps to become the
5654
// current `NowPlayable` app, by deactivating an audio session, or setting a playback
5755
// state, depending on platform.
5856
func handleNowPlayableSessionEnd() {
59-
#if os(macOS)
60-
MPNowPlayingInfoCenter.default().playbackState = .stopped
61-
#endif
57+
MPNowPlayingInfoCenter.default().playbackState = .stopped
6258
}
6359

6460
// Customization point: update the Now Playing Info metadata with application-supplied
@@ -80,16 +76,12 @@ public extension NowPlayableService {
8076
// Note that the playback position, once set, is updated automatically according to
8177
// the playback rate. There is no need for explicit period updates from the app.
8278
func handleNowPlayablePlaybackChange(isPlaying: Bool) {
83-
#if os(macOS)
84-
MPNowPlayingInfoCenter.default().playbackState = isPlaying ? .playing : .paused
85-
#endif
79+
MPNowPlayingInfoCenter.default().playbackState = isPlaying ? .playing : .paused
8680
}
8781

8882
func handleNowPlayablePlaybackChange(isPlaying: Bool, metadata: NowPlayableDynamicMetadata) {
8983
setNowPlayingPlaybackInfo(metadata)
90-
#if os(macOS)
91-
handleNowPlayablePlaybackChange(isPlaying: isPlaying)
92-
#endif
84+
handleNowPlayablePlaybackChange(isPlaying: isPlaying)
9385
}
9486

9587
// Install handlers for registered commands, and disable commands as necessary.

0 commit comments

Comments
 (0)