Skip to content

Commit 021ebf6

Browse files
committed
Fixed #452. Player state is now accurate without interaction
1 parent 1cf472b commit 021ebf6

File tree

10 files changed

+68
-83
lines changed

10 files changed

+68
-83
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ icon*
77
.vscode
88
.sass-cache
99
logs/
10+
.nova/
1011

1112
# AmplitudeJS Specifics
1213
songs/*
1314
examples/testing/*
1415
src/PENDING
1516
examples/songs
1617
coverage/
17-
ui-tests/*
18+
ui-tests/

dist/amplitude.js

Lines changed: 41 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/amplitude.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/amplitude.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/core.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ import Debug from "../utilities/debug.js";
4646
*/
4747
import Visualizations from "../fx/visualizations.js";
4848

49+
/**
50+
* Import the Config State module.
51+
* @module utilities/configState
52+
*/
53+
import ConfigState from "../utilities/configState.js";
54+
4955
/**
5056
* Interacts directly with native functions of the Audio element. Logic
5157
* leading up to these methods are handled by click handlers which call
@@ -102,6 +108,11 @@ let Core = (function() {
102108
}
103109
config.audio.play();
104110
config.audio.playbackRate = config.playback_speed;
111+
112+
/*
113+
Sets the state of the player.
114+
*/
115+
ConfigState.setPlayerState();
105116
}
106117

107118
/**
@@ -123,14 +134,20 @@ let Core = (function() {
123134
Flag that pause button was clicked.
124135
*/
125136
config.paused = true;
126-
137+
138+
127139
/*
128140
If the song is live, we disconnect the stream so we aren't
129141
saving it to memory.
130142
*/
131143
if (config.active_metadata.live) {
132144
disconnectStream();
133145
}
146+
147+
/*
148+
Sets the state of the player.
149+
*/
150+
ConfigState.setPlayerState();
134151
}
135152

136153
/**
@@ -164,6 +181,11 @@ let Core = (function() {
164181
disconnectStream();
165182
}
166183

184+
/*
185+
Sets the state of the player.
186+
*/
187+
ConfigState.setPlayerState();
188+
167189
/*
168190
Run the stop callback
169191
*/

src/events/pause.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ let Pause = (function() {
8282
if (playlistAttribute != null && songIndexAttribute != null) {
8383
handleSongInPlaylistPause(playlistAttribute, songIndexAttribute);
8484
}
85-
86-
ConfigState.setPlayerState();
8785
}
8886
}
8987

src/events/play.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ let Play = (function() {
9494
if (playlistAttribute != null && songIndexAttribute != null) {
9595
handleSongInPlaylistPlay(playlistAttribute, songIndexAttribute);
9696
}
97-
98-
ConfigState.setPlayerState();
9997
}
10098
}
10199

src/events/playPause.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ let PlayPause = (function() {
9191
if (playlist != null && song != null) {
9292
handleSongInPlaylistPlayPause(playlist, song);
9393
}
94-
95-
ConfigState.setPlayerState();
9694
}
9795
}
9896

src/events/stop.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ let Stop = (function() {
4949
Stops the active song.
5050
*/
5151
Core.stop();
52-
53-
/*
54-
Set the state of the player.
55-
*/
56-
ConfigState.setPlayerState();
5752
}
5853
}
5954

src/index.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -761,10 +761,6 @@ let Amplitude = (function() {
761761
*/
762762
TimeElements.resetDurationTimes();
763763

764-
/*
765-
Sets the state of the player.
766-
*/
767-
ConfigState.setPlayerState();
768764
}
769765

770766
/**
@@ -802,11 +798,6 @@ let Amplitude = (function() {
802798
*/
803799
Core.play();
804800

805-
/*
806-
Sets the state of the player.
807-
*/
808-
ConfigState.setPlayerState();
809-
810801
/*
811802
Sync all of the play pause buttons.
812803
*/
@@ -858,11 +849,6 @@ let Amplitude = (function() {
858849
Play the song
859850
*/
860851
Core.play();
861-
862-
/*
863-
Set the state of the player
864-
*/
865-
ConfigState.setPlayerState();
866852
}
867853

868854
/**
@@ -876,8 +862,6 @@ let Amplitude = (function() {
876862
*/
877863
function play() {
878864
Core.play();
879-
880-
ConfigState.setPlayerState();
881865
}
882866

883867
/**
@@ -891,8 +875,6 @@ let Amplitude = (function() {
891875
*/
892876
function pause() {
893877
Core.pause();
894-
895-
ConfigState.setPlayerState();
896878
}
897879

898880
/**
@@ -905,8 +887,6 @@ let Amplitude = (function() {
905887
*/
906888
function stop() {
907889
Core.stop();
908-
909-
ConfigState.setPlayerState();
910890
}
911891

912892
/**

0 commit comments

Comments
 (0)