From 819187730a5b74a52ff1895625cf7b3c94c6ad9b Mon Sep 17 00:00:00 2001 From: dakkar Date: Wed, 22 Dec 2021 14:03:30 +0000 Subject: some renaming --- lib/App/MediaControl.rakumod | 35 +++++++++++++++++++++++++++++++++++ lib/Vlc/App.rakumod | 33 --------------------------------- 2 files changed, 35 insertions(+), 33 deletions(-) create mode 100644 lib/App/MediaControl.rakumod delete mode 100644 lib/Vlc/App.rakumod (limited to 'lib') diff --git a/lib/App/MediaControl.rakumod b/lib/App/MediaControl.rakumod new file mode 100644 index 0000000..bd4a2c9 --- /dev/null +++ b/lib/App/MediaControl.rakumod @@ -0,0 +1,35 @@ +use v6.d; +use Cro::HTTP::Server; +use Cro::HTTP::Router; +use Vlc::Client; +use Lirc::Client; + +class App::MediaControl { + has Vlc::Client $.vlc is required; + has Lirc::Client $.lirc is required; + has Int $.port = 8080; + has Cro::Service $!service handles ; + + method start() { + my $application = route { + resources-from %?RESOURCES; + + get -> { resource 'vlc.html' } + + post -> 'play' { await self.vlc.command('pl_play') } + post -> 'pause' { await self.vlc.command('pl_pause') } + post -> 'stop' { await self.vlc.command('pl_stop') } + + get -> 'status' { + my $status = await self.vlc.status(); + content 'application/json', $status; + } + }; + + $!service = Cro::HTTP::Server.new( + :port(self.port), :$application, + ); + + return $!service.start(); + } +} diff --git a/lib/Vlc/App.rakumod b/lib/Vlc/App.rakumod deleted file mode 100644 index e4401e6..0000000 --- a/lib/Vlc/App.rakumod +++ /dev/null @@ -1,33 +0,0 @@ -use v6.d; -use Cro::HTTP::Server; -use Cro::HTTP::Router; -use Vlc::Client; - -class Vlc::App { - has Vlc::Client $.vlc is required; - has Int $.port = 8080; - has Cro::Service $!service handles ; - - method start() { - my $application = route { - resources-from %?RESOURCES; - - get -> { resource 'vlc.html' } - - post -> 'play' { await self.vlc.command('pl_play') } - post -> 'pause' { await self.vlc.command('pl_pause') } - post -> 'stop' { await self.vlc.command('pl_stop') } - - get -> 'status' { - my $status = await self.vlc.status(); - content 'application/json', $status; - } - }; - - $!service = Cro::HTTP::Server.new( - :port(self.port), :$application, - ); - - return $!service.start(); - } -} -- cgit v1.2.3