Skip to content

Commit

Permalink
fix: fix for macos
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelOsborne committed Nov 27, 2024
1 parent f2be1be commit f20102e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions Sources/DotLottie/Public/DotLottieAnimation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ public final class DotLottieAnimation: ObservableObject {

internal var config: Config

#if os(iOS)
internal var dotLottieAnimationView: DotLottieAnimationView?

#endif

internal var dotLottieView: DotLottieView?

/// Load directly from a String (.json).
Expand Down Expand Up @@ -58,7 +60,6 @@ public final class DotLottieAnimation: ObservableObject {
webURL: String,
config: AnimationConfig
) {
print(">> LOADING")
self.init(config: config) {
if webURL.contains(".lottie") {
try await $0.loadDotLottieFromURL(url: webURL)
Expand Down
10 changes: 6 additions & 4 deletions Sources/DotLottie/Public/Player.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class Player: ObservableObject {
self.setPlayerState(state: .error)
throw AnimationLoadErrors.loadAnimationDataError
}

setPlayerState(state: self.config().autoplay ? .playing : .draw)
}

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

public func play() -> Bool {
let play = dotLottiePlayer.play()
if (play) {

if (dotLottiePlayer.isPlaying()) {
self.setPlayerState(state: .playing)
}

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

if (pause) {
if (dotLottiePlayer.isPaused()) {
self.setPlayerState(state: .paused)
}

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

if (stop) {
if (dotLottiePlayer.isStopped()) {
self.setPlayerState(state: .stopped)
}

Expand Down

0 comments on commit f20102e

Please sign in to comment.