Specifications

5.3.8.2 Extracting the song name
To get the song name to the LCD from the filename, it was necessary to extract the
required string from the songs entry in the play list and send this to the player, which
would simply have to display it. Another socket was created just to send the song name.
A thread was created on the player that prints anything (using the print screen function)
that is received through this socket. On the server, the task is more complex. It was
decided that the appropriate time to send the song name is when the server calls the
openMP3 function, which reads from the play list file the file name and path and stores
the information in a buffer.
A function was created to extract the song name from this buffer, and store it in another
buffer and send it to the player. This function works by first shuffling through the path
and the filtering out the song name from the file name. This function is called
send_song_name and within this function another function is called
(add_number_song_name) to place a song number string in front of song name. The
send_song_name function searches through the buffer as shown in figure 27.
Add song
number to the
start of the
song buffer
Next 4
items in the
path buffer
'.mp3'
Add current
item from path
buffer to song
buffer
Increment the
position in both
buffers
Next item
in path
buffer '\'
Next 3
items in the
path buffer
' - '
Rest the position
in the song buffer
to the start
Increment the
position in the
path buffer
Increment 3
positions in the
path buffer
NULL terminate the
song buffer and
send to the player
No
No
No
Yes Yes
Yes
Figure 27 Song name extraction
56