Closed kd1889 closed 3 years ago
TESTS
Test 1 - Update playlist while it is playing:
Currently playlist 1 has one song in it, tenderness.mp3
. As shown on the flask:
As shown in the terminal after selecting to play playlist 1:
In the web UI, the songs in the playlist were changed to the following and submitted:
The terminal shows that the playlist was changed and the new song was started:
Test 2: Update playing 1/2 while playing the other playlist Goal: Assume playlist 1 is playing, updating playlist 2 should not stop playlist 1 from playing, while still changing playlist 2.
Terminal shows playlist 1 was selected:
Web UI shows current songs in playlist 1 and playlist 2, respectively:
Playlist 2 is changed as follows and submitted. Terminal shows that the song is unchanged:
Test 3 - Modify radio station while playing playlist and vice versa. Goal: in either, update should not interfere with the play of radio or playlist accordingly.
Playing playlist:
Radio station was updated, and the playlist kept playing:
Playing radio:
Playlist 1 and 2 were updated and radio kept playing:
Test 4 - Upload a music file without interfering with either radio or playlist:
With radio playing:
Uploaded bensound-energy.mp3:
Radio was still playing
With playlist:
Uploaded bensound-betterdays.mp3:
Playlist was still playing
Shows successful upload and the new music can be selected for playlists:
Multiple pushes were done due to using github to edit code, as the command line was difficult to modify.
The following lines were added with explanation:
The load_trackList
function was added to the MusicPlayer
class in order to seamlessly change the current playlist to be played. It was used in the PlaySomething
class.
def load_trackList(self, PLAYLIST):
self.trackList = PLAYLIST;
self.index = 0;
The PlaySomething
was updated to hold the information regarding the playlists, and the radio stations based on the configuration files. Some information is repeated but can be easily resolved by changing/removing the variables that are repeats. Currently still kept to reduce errors.
class PlaySomething(Page):
FEATURES = ["Radio 1", "Playlist 1", "More"]
def __init__(self):
super().__init__(self.FEATURES)
#Inital setup of the configuration value
#Using flask-app + threads, update these values
self.STATIONS = radio.create_stations(CONFIG_RADIO)[0];
self.NUM_STATIONS = radio.create_stations(CONFIG_RADIO)[1];
self.PLAYLIST_1 = radio.create_playlist(CONFIG_PLAYLIST, 1);
self.PLAYLIST_2 = radio.create_playlist(CONFIG_PLAYLIST, 2);
self.PLAYLISTS = [self.PLAYLIST_1, self.PLAYLIST_2];
radio.setup_station(self.STATIONS);
#Attributes to control radio + music player
self.isLocked = False # parental lock
self.isRadioPlaying = False
self.isMusicOnly = True
self.radio_number = 0 # radio number on screen - 1
self.playlist_number = 0 # playlist number on screen - 1
self.number_of_playlists = len(self.PLAYLISTS);
self.number_of_stations = self.NUM_STATIONS;
#music player to swap between tracks and radio stations
self.musicPlayer = MusicPlayer()
#self.musicPlayer.start();
self.musicPlayer.load_trackList(self.PLAYLISTS[self.playlist_number]);
if (self.NUM_STATIONS != 0):
self.play_radio_station();
else:
self.FEATURES[0] = "No station"
The updated_playlist
and update_radio
function took in the configuration dictionaries for their corresponding files. These functions were called in their corresponding flask-app function, radio_1()
and playlist1
/ playlist2
, respectively.
def update_playlist(self, new_playlist, playlist_num):
changed = -1;
if (playlist_num > 2):
return;
new_trackList = radio.create_playlist(new_playlist, playlist_num);
if new_trackList is None:
new_trackList = [];
for i in range(len(self.PLAYLISTS)):
if i == playlist_num - 1:
self.PLAYLISTS[i] = new_trackList;
if i == self.playlist_number:
self.musicPlayer.load_trackList(new_trackList);
changed = i;
print(changed);
if (not self.isRadioPlaying and changed == self.playlist_number):
print(changed);
self.stop_player();
self.play_track();
def update_radio(self, new_radio):
self.STATIONS = radio.create_stations(new_radio)[0];
self.NUM_STATIONS = radio.create_stations(new_radio)[1];
self.number_of_stations = self.NUM_STATIONS;
if self.NUM_STATIONS == 0:
self.FEATURES[0] = "No station"
else:
self.FEATURES[0] = "Radio 1"
print(self.STATIONS, self.NUM_STATIONS);
radio.radio_reset();
radio.setup_station(self.STATIONS);
self.radio_number = 0;