aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Wittig <michael.wittig@fu-berlin.de>2010-10-14 17:38:35 +0200
committerMichael Wittig <michael.wittig@fu-berlin.de>2010-10-14 17:38:35 +0200
commit4741ca84bd516bcf5b65854e2661f7842599c4fc (patch)
treea68569791dec865c0ed9504d421dcc74827e3a31
parent66fb7971606ff0833b6ae1836e4dc05d83ee0c82 (diff)
downloaderlang-4741ca84bd516bcf5b65854e2661f7842599c4fc.tar.gz
erlang-4741ca84bd516bcf5b65854e2661f7842599c4fc.tar.xz
erlang-4741ca84bd516bcf5b65854e2661f7842599c4fc.zip
added getting votes after songs
-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.