Skip to content

Commit f20102e

Browse files
committed
fix: fix for macos
1 parent f2be1be commit f20102e

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Sources/DotLottie/Public/DotLottieAnimation.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ public final class DotLottieAnimation: ObservableObject {
2222

2323
internal var config: Config
2424

25+
#if os(iOS)
2526
internal var dotLottieAnimationView: DotLottieAnimationView?
26-
27+
#endif
28+
2729
internal var dotLottieView: DotLottieView?
2830

2931
/// Load directly from a String (.json).
@@ -58,7 +60,6 @@ public final class DotLottieAnimation: ObservableObject {
5860
webURL: String,
5961
config: AnimationConfig
6062
) {
61-
print(">> LOADING")
6263
self.init(config: config) {
6364
if webURL.contains(".lottie") {
6465
try await $0.loadDotLottieFromURL(url: webURL)

Sources/DotLottie/Public/Player.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class Player: ObservableObject {
5151
self.setPlayerState(state: .error)
5252
throw AnimationLoadErrors.loadAnimationDataError
5353
}
54+
55+
setPlayerState(state: self.config().autoplay ? .playing : .draw)
5456
}
5557

5658
public func loadAnimationPath(animationPath: String, width: Int, height: Int) throws {
@@ -167,8 +169,8 @@ class Player: ObservableObject {
167169

168170
public func play() -> Bool {
169171
let play = dotLottiePlayer.play()
170-
171-
if (play) {
172+
173+
if (dotLottiePlayer.isPlaying()) {
172174
self.setPlayerState(state: .playing)
173175
}
174176

@@ -178,7 +180,7 @@ class Player: ObservableObject {
178180
public func pause() -> Bool {
179181
let pause = dotLottiePlayer.pause()
180182

181-
if (pause) {
183+
if (dotLottiePlayer.isPaused()) {
182184
self.setPlayerState(state: .paused)
183185
}
184186

@@ -188,7 +190,7 @@ class Player: ObservableObject {
188190
public func stop() -> Bool {
189191
let stop = dotLottiePlayer.stop()
190192

191-
if (stop) {
193+
if (dotLottiePlayer.isStopped()) {
192194
self.setPlayerState(state: .stopped)
193195
}
194196

0 commit comments

Comments
 (0)