diff options
author | dakkar <dakkar@thenautilus.net> | 2021-12-30 10:45:09 +0000 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2021-12-30 10:45:09 +0000 |
commit | 14bbc21cf5ae12089d51c139bfabd159a1b94f29 (patch) | |
tree | 077f42dfa95e2b6d1b6e7effdafab81d85b99092 /lib | |
parent | rename matpath→path (diff) | |
download | media-control-14bbc21cf5ae12089d51c139bfabd159a1b94f29.tar.gz media-control-14bbc21cf5ae12089d51c139bfabd159a1b94f29.tar.bz2 media-control-14bbc21cf5ae12089d51c139bfabd159a1b94f29.zip |
play from media list
Diffstat (limited to 'lib')
-rw-r--r-- | lib/App/MediaControl.rakumod | 1 | ||||
-rw-r--r-- | lib/App/MediaControl/Web.rakumod | 6 | ||||
-rw-r--r-- | lib/Vlc/Client.rakumod | 12 |
3 files changed, 17 insertions, 2 deletions
diff --git a/lib/App/MediaControl.rakumod b/lib/App/MediaControl.rakumod index b03e31b..82dc0dd 100644 --- a/lib/App/MediaControl.rakumod +++ b/lib/App/MediaControl.rakumod @@ -19,6 +19,7 @@ class App::MediaControl { $!vlc .= new( password => $!config<vlc><password>, base-uri => $!config<vlc><base-uri>, + mrl-root => $!config<media><root>, ); $!lirc-client .= new(); diff --git a/lib/App/MediaControl/Web.rakumod b/lib/App/MediaControl/Web.rakumod index c577d90..cb12783 100644 --- a/lib/App/MediaControl/Web.rakumod +++ b/lib/App/MediaControl/Web.rakumod @@ -15,6 +15,12 @@ class App::MediaControl::Web { method start() { my $vlc = route { post -> 'play' { await self.vlc.command('pl_play') } + post -> 'play', Int:D $id { + my $file = self.db.get-entry($id); + await self.vlc.play-file(|%( + $file<path name>:p # no comma! + )); + } post -> 'pause' { await self.vlc.command('pl_pause') } post -> 'stop' { await self.vlc.command('pl_stop') } diff --git a/lib/Vlc/Client.rakumod b/lib/Vlc/Client.rakumod index 3620d47..5b19c53 100644 --- a/lib/Vlc/Client.rakumod +++ b/lib/Vlc/Client.rakumod @@ -20,8 +20,9 @@ class Vlc::Client { has Cro::HTTP::Client $!vlc; has Str $.password is required; has Str $.base-uri = 'http://127.0.0.1:8080/requests/'; + has IO::Path() $.mrl-root = '/'; - method !call-vlc(Str $path, *%args) { + method !call-vlc(Str:D $path, *%args) { $!vlc ||= Cro::HTTP::Client.new( auth => { :username(), :password(self.password) }, add-body-parsers => [ Cro::BodyParser::VlcXML ], @@ -34,10 +35,17 @@ class Vlc::Client { ); } - method command(Str $command, *%args) { + method command(Str:D $command, *%args) { return self!call-vlc('status.xml', :$command, |%args); } + method play-file(Str:D :$path, Str:D :$name) { + return self.command( + 'in_play', + input => self.mrl-root.child($path).child($name), + ); + } + method status() { my $res = await self!call-vlc('status.xml'); my XML::Document $status = await $res.body; |