From 4741ca84bd516bcf5b65854e2661f7842599c4fc Mon Sep 17 00:00:00 2001 From: Michael Wittig Date: Thu, 14 Oct 2010 17:38:35 +0200 Subject: added getting votes after songs --- server/media.erl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'server') 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. -- cgit v1.2.3