Skip to content

Commit

Permalink
fix: split adding audioFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelOsborne committed Sep 13, 2023
1 parent 4ce48ac commit 001386e
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions packages/common/src/dotlottie-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1751,6 +1751,8 @@ export class DotLottiePlayer {
loop,
}));

let audioFactory;

if (this._animation && lottieContainsAudio(this._animation)) {
if (this._howlerInstance) {
this._howlerInstance.unload();
Expand All @@ -1764,14 +1766,23 @@ export class DotLottiePlayer {
return this._howlerInstance;
};

options['audioFactory'] = howl;
audioFactory = howl;
}

this._lottie = lottiePlayer.loadAnimation({
...options,
container: this._container as Element,
animationData: this._animation,
});
if (audioFactory) {
this._lottie = lottiePlayer.loadAnimation({
...options,
container: this._container as Element,
animationData: this._animation,
audioFactory,
});
} else {
this._lottie = lottiePlayer.loadAnimation({
...options,
container: this._container as Element,
animationData: this._animation,
});
}

this.addEventListeners();

Expand Down

0 comments on commit 001386e

Please sign in to comment.