aboutsummaryrefslogtreecommitdiffstats
path: root/server/media.erl
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--server/media.erl11
1 files changed, 10 insertions, 1 deletions
diff --git a/server/media.erl b/server/media.erl
index 5eea592..83e7513 100644
--- a/server/media.erl
+++ b/server/media.erl
@@ -112,11 +112,20 @@ play(Artist, Title) ->
io:format("playing: ~s, Artist: ~s~n", [Title, Artist]),
receive
- {Port, {exit_status, 0}} -> start_playing();
+ {Port, {exit_status, 0}} -> give_votes(cldb:ask("_","_")), start_playing();
{Port, {exit_status, S}} -> throw({commandfailed, S})
end.
+% after a song every client gets on more vote
+give_votes([Head|Rest]) ->
+ User = Head#user.name,
+ Pwd = Head#user.passwd,
+ cldb:incVote(User, Pwd),
+ giveVotes(Rest);
+give_Votes([]) -> ok.
+
+
% Of course we need a query to find out what the highest voted track is.
% We accomplish this by requesting all the records from the database and then iterate over them, just taking a look at the vote
% variable, so it is like a list of integers. In case no tracks were voted for we just take the first track we found and play it. Of course this song is locked afterwards so a different one will be chosen.