From f2164544210f511664ed7186107789ec55ec3edf Mon Sep 17 00:00:00 2001 From: Michael Wittig Date: Thu, 14 Oct 2010 17:49:42 +0200 Subject: finally finished, need to be read again --- server/cldb.erl | 8 ++++++++ server/media.erl | 11 +---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/server/cldb.erl b/server/cldb.erl index 0602b7d..d514ff9 100644 --- a/server/cldb.erl +++ b/server/cldb.erl @@ -59,3 +59,11 @@ incVote(User) -> check_rights(User) -> {_, _, Rights} = ask(User, '_'), Rights. + +% after a song every client gets on more vote +give_votes([Head|Rest]) -> + User = Head#user.name, + incVote(User), + give_votes(Rest); +give_votes([]) -> ok. + diff --git a/server/media.erl b/server/media.erl index 83e7513..80a3fea 100644 --- a/server/media.erl +++ b/server/media.erl @@ -112,20 +112,11 @@ play(Artist, Title) -> io:format("playing: ~s, Artist: ~s~n", [Title, Artist]), receive - {Port, {exit_status, 0}} -> give_votes(cldb:ask("_","_")), start_playing(); + {Port, {exit_status, 0}} -> cldb: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