Skip to content

Commit 43840d6

Browse files
committed
chore: removed console logs
1 parent ef10891 commit 43840d6

File tree

1 file changed

+56
-9
lines changed

1 file changed

+56
-9
lines changed

src/Player.vue

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,62 @@ export default {
139139
this.options.playing = true;
140140
}
141141
},
142-
toggleLoop() {
143-
if (this.options.loop) {
144-
this.player.setLooping(false);
145-
this.options.loop = false;
146-
} else {
147-
this.player.setLooping(true);
148-
this.options.loop = true;
149-
this.options.playing = true;
150-
this.player.play();
142+
mounted() {
143+
this.player = this.$refs.player;
144+
this.player.addEventListener('ready', function () {
145+
this.options.animation = this.player.getLottie();
146+
this.loading = false;
147+
}.bind(this));
148+
this.player.addEventListener('complete', function () {
149+
this.stop();
150+
}.bind(this));
151+
this.options.backgroundColor = this.backgroundColor;
152+
this.options.speed = this.speed;
153+
this.options.loop = this.loop;
154+
this.options.playing = this.autoplay;
155+
},
156+
methods: {
157+
togglePlayPause() {
158+
if (this.options.playing) {
159+
this.player.pause();
160+
this.options.playing = false;
161+
} else {
162+
this.player.play();
163+
this.options.playing = true;
164+
}
165+
},
166+
toggleLoop() {
167+
if (this.options.loop) {
168+
this.player.setLooping(false);
169+
this.options.loop = false;
170+
} else {
171+
this.player.setLooping(true);
172+
this.options.loop = true;
173+
this.options.playing = true;
174+
this.player.play();
175+
}
176+
},
177+
setPlayerSpeed(speed) {
178+
this.player.setSpeed(speed);
179+
this.$emit('setPlayerSpeed', speed);
180+
},
181+
stop() {
182+
this.player.seek(1);
183+
this.player.stop();
184+
this.options.playing = false;
185+
},
186+
setBackgroundColor(color) {
187+
this.options.backgroundColor = color;
188+
this.$emit('setBackgroundColor', color);
189+
},
190+
toggleFullscreen() {
191+
this.$emit('toggleFullscreen');
192+
},
193+
getLottie() {
194+
return (this.options.animation);
195+
},
196+
getPlayerState() {
197+
return (this.player.currentState);
151198
}
152199
},
153200
setPlayerSpeed(speed) {

0 commit comments

Comments
 (0)