Skip to content

Commit

Permalink
Implement .status
Browse files Browse the repository at this point in the history
  • Loading branch information
zoffixznet committed Jun 6, 2018
1 parent a3d6dd2 commit 0f66571
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Expand Up @@ -63,6 +63,10 @@ else {
}
```

# EXAMPLES

See [`examples/`](examples/) dir for some examples of module's use.

# DESCRIPTION

Provides programmatic interface to
Expand Down Expand Up @@ -197,6 +201,15 @@ Seeks the current track based on the given `$val`. Per

Using too-large values (e.g. `+220%`) is perfectly acceptable.

### `.status`

```perl6
method status(--> DOM::Tiny:D)
```

Fetches the XML of a bunch of info of the current status and returns it as
[`DOM::Tiny` object](https://modules.perl6.org/repo/DOM::Tiny)

### `.stop`

```perl6
Expand Down
2 changes: 2 additions & 0 deletions examples/vlc.p6
Expand Up @@ -29,3 +29,5 @@ multi MAIN('prev') { $vlc.prev }
multi MAIN('seek', $val) { $vlc.seek: $val }
#|(set volume)
multi MAIN('vol', $val) { $vlc.volume: $val }
#|(show current status)
multi MAIN('status') { say ~$vlc.status }
9 changes: 9 additions & 0 deletions lib/WWW/vlc/Remote.pm6
Expand Up @@ -102,6 +102,15 @@ method seek (\v where Str:D|Numeric:D = '0%' --> ::?CLASS:D) {
self!com-self: 'seek&val=' ~ uri_encode_component v
}

method status (--> DOM::Tiny:D) {
my $res := $!ua.get: self!path: '/requests/status.xml';
$res.is-success or fail X::Network.new: :$res;
my $dom := DOM::Tiny.parse($res.content);
fail X.new: error => $dom.at('h1').all-text ~ "\n" ~ $dom.at('pre').all-text
if $dom.at('title').all-text andthen .starts-with: 'Error loading';
$dom
}

method toggle-random (--> ::?CLASS:D) { self!com-self: 'pl_random' }
method toggle-loop (--> ::?CLASS:D) { self!com-self: 'pl_loop' }
method toggle-repeat (--> ::?CLASS:D) { self!com-self: 'pl_repeat' }
Expand Down

0 comments on commit 0f66571

Please sign in to comment.