aboutsummaryrefslogtreecommitdiffstats
path: root/server/media.erl
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--server/media.erl21
1 files changed, 19 insertions, 2 deletions
diff --git a/server/media.erl b/server/media.erl
index a761f64..3678ff3 100644
--- a/server/media.erl
+++ b/server/media.erl
@@ -1,5 +1,5 @@
-module(media).
--export([init/0,insert/3, ask/2]).
+-export([init/0,insert/3, ask/2, all/0, play/3]).
% Since we are not willing to calculate and deliver all the id3 tags everytime they are requested,
% we try to get something persistent with mnesia.
@@ -42,5 +42,22 @@ ask(Artist, Title) ->
{atomic, Results} = mnesia:transaction(F),
Results.
+% Just in case the client is interested in everything we got.
+
+all() ->
+ F = fun() ->
+ mnesia:match({track, '_','_','_','_','_'})
+ end,
+ {atomic, Results} = mnesia:transaction(F),
+ Results.
+
% We want to play mp3s from our database.
-play(Artist, Title) -> io:format("blub").
+
+play(Artist, Title, Callback) ->
+ [Head|_] = ask(Artist, Title),
+ {_, artist, title, _, _, fp} = Head,
+ Cmd = "mplayer -quiet " ++ fp,
+ Port = erlang:open_port({spawn, Cmd}, [exit_status]).
+
+% We want to execute commands locally
+