Net-Async-MPD-0.005000755001750001750 013403007516 14167 5ustar00jjatriajjatria000000000000Changes100644001750001750 145113403007516 15544 0ustar00jjatriajjatria000000000000Net-Async-MPD-0.005Revision history for Net-Async-MPD 0.005 2018-12-08 18:37:01+00:00 Europe/London * Fixes: * Fixed an issue with the parser for grouped results ignoring the last line of input 0.004 2018-01-29 23:03:08+00:00 Europe/London * Fixes: * Some minor documentation fixes (typos, etc) and expansions * Changes: * Tests no longer fail when warnings are found, pending a more permanent solution to the warnings thrown by upstream modules in some cases. 0.003 2018-01-23 21:56:11+00:00 Europe/London * Fixes: * Command list in send() is validates after processing * Small fixes and corrections in the documentation 0.002 2018-01-23 20:09:50+00:00 Europe/London Initial release, as a port to IO::Async of AnyEvent::Net::MPD LICENSE100644001750001750 4370513403007516 15306 0ustar00jjatriajjatria000000000000Net-Async-MPD-0.005This software is copyright (c) 2018 by José Joaquín Atria. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2018 by José Joaquín Atria. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2018 by José Joaquín Atria. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End dist.ini100644001750001750 210013403007516 15705 0ustar00jjatriajjatria000000000000Net-Async-MPD-0.005name = Net-Async-MPD author = José Joaquín Atria license = Perl_5 copyright_holder = José Joaquín Atria copyright_year = 2018 [Git::GatherDir] [ReadmeAnyFromPod / MarkdownInBuild] filename = README.md [CopyFilesFromBuild] copy = README.md [@Filter] -bundle = @Basic -remove = GatherDir -remove = Readme [PodSyntaxTests] [NextRelease] [Repository] repository = git://gitlab.com/jjatria/Net-Async-MPD.git web = https://gitlab.com/jjatria/Net-Async-MPD [Bugtracker] web = https://gitlab.com/jjatria/Net-Async-MPD/issues mailto = jjatria at cpan.org [MinimumPerl] [MetaJSON] [MetaProvides::Package] [RewriteVersion] [BumpVersionAfterRelease] [Git::Contributors] [Git::CommitBuild] release_branch = build branch = [Git::Tag / release] branch = build [Git::Tag / devel] branch = master tag_format = v%v-devel [AutoPrereqs] [Prereqs] Role::EventEmitter = 0.002 IO::Async = 0.66 IO::Socket::IP = 0.39 Log::Any = 1.049 Moo = 2.003002 MooX::HandlesVia = 0.001008 Types::Standard = 1.000006 [Prereqs / TestRequires] Test::More = 1.302078 Try::Tiny = 0.28 META.yml100644001750001750 246413403007516 15527 0ustar00jjatriajjatria000000000000Net-Async-MPD-0.005--- abstract: 'A non-blocking interface to MPD' author: - 'José Joaquín Atria ' build_requires: File::Share: '0' File::Which: '0' IO::Async::Timer::Periodic: '0' Net::EmptyPort: '0' Path::Tiny: '0' Scope::Guard: '0' Test::More: '1.302078' Try::Tiny: '0.28' Types::Path::Tiny: '0' lib: '0' perl: '5.010' configure_requires: ExtUtils::MakeMaker: '0' File::ShareDir::Install: '0.06' perl: '5.010' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.012, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Net-Async-MPD provides: Net::Async::MPD: file: lib/Net/Async/MPD.pm version: '0.005' requires: Carp: '0' Future::Utils: '0' IO::Async: '0.66' IO::Async::Loop: '0' IO::Async::Stream: '0' IO::Socket::IP: '0.39' Log::Any: '1.049' Moo: '2.003002' MooX::HandlesVia: '0.001008' Role::EventEmitter: '0.002' Scalar::Util: '0' Types::Standard: '1.000006' namespace::clean: '0' perl: '5.010' strict: '0' warnings: '0' resources: bugtracker: https://gitlab.com/jjatria/Net-Async-MPD/issues repository: git://gitlab.com/jjatria/Net-Async-MPD.git version: '0.005' x_generated_by_perl: v5.26.2 x_serialization_backend: 'YAML::Tiny version 1.73' MANIFEST100644001750001750 54713403007516 15367 0ustar00jjatriajjatria000000000000Net-Async-MPD-0.005# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.012. Changes LICENSE MANIFEST META.json META.yml Makefile.PL README.md dist.ini examples/chat.pl examples/emitter.pl examples/endless.pl examples/re.pl lib/Net/Async/MPD.pm share/mpd.conf.template share/mpd.pod t/author-pod-syntax.t t/basic.t t/connection.t t/lib/Test/Server/MPD.pm README.md100644001750001750 3322713403007516 15556 0ustar00jjatriajjatria000000000000Net-Async-MPD-0.005# NAME Net::Async::MPD - A non-blocking interface to MPD # SYNOPSIS use Net::Async::MPD; my $mpd = Net::Async::MPD->new( host => 'localhost', auto_connect => 1, ); my @subsystems = qw( player mixer database ); # Register a listener foreach my $subsystem (@subsystems) { $mpd->on( $subsystem => sub { my ($self) = @_; print "$subsystem has changed\n"; # Stop listening if mixer changes $mpd->noidle if $subsystem eq 'mixer'; }); } # Send a command my $stats = $mpd->send( 'stats' ); # Or in blocking mode my $status = $mpd->send( 'status' )->get; # Which is the same as $status = $mpd->get( 'status' ); print 'Server is in ', $status->{state}, " state\n"; print 'Server has ', $stats->get->{albums}, " albums in the database\n"; # Put the client in looping idle mode my $idle = $mpd->idle( @subsystems ); # Set the emitter in motion, until the next call to noidle $idle->get; # DESCRIPTION [Net::Async::MPD](https://metacpan.org/pod/Net::Async::MPD) provides a non-blocking interface to an MPD server. ## Command Lists MPD supports sending command lists to make it easier to perform a series of steps as a single one. No command is executed until all commands in the list have been sent, and then the server returns the result for all of them together. See the [MPD documentation](https://musicpd.org/doc/protocol/command_lists.html) for more information. [Net::Async::MPD](https://metacpan.org/pod/Net::Async::MPD) fully supports sending command lists, and makes it easy to structure the results received from MPD, or not to if the user so desires. See the ["send"](#send) method for more information. ## Error Handling Most operations in this module return [Future](https://metacpan.org/pod/Future) objects, and to keep things consistent, any errors that are encountered during processing will result in those futures being failed or canceled as appropriate. This module _also_ makes use of the events in [Role::EventEmitter](https://metacpan.org/pod/Role::EventEmitter), which provides it's own method for error handling: the `error` event. Normally, if a class `does` that role, it is expected that users will register some listener to the `error` event to handle failures. However, since errors are alredy being handled by the Futures (one woudl hope), this distribution registers a dummy listener to the `error` event, and turns into one that is mostly useful for debugging and monitoring. Of course, the author cannot really stop overly zealous users from [unsubscribing](https://metacpan.org/pod/Role::EventEmitter#unsubscribe) the error dummy listener, but they do so at their own risk. ## Server Responses MPD normally returns results as a flat list of response lines. [Net::Async::MPD](https://metacpan.org/pod/Net::Async::MPD) tries to make it easier to provide some structure to these responses by providing pre-set parser subroutines for each command. Although the default parser will be fine in most cases, it is possible to override this with a custom parser, or to disable the parsing entirely to get the raw lines from the server. For information on how to override the parser, see the documentation for the ["send"](#send) method. By default, the results of each command are parsed independently, and passed to the [Future](https://metacpan.org/pod/Future) returned by the corresponding call to ["send"](#send). This is true regardless of whether those commands were sent as part of a list or not. This means that, by default, the [Future](https://metacpan.org/pod/Future) that represents a given call to ["send"](#send) will receive the results of as many commands as were originall sent. This might not be desireable when eg. sending multiple commands whose results should be aggregated. In those cases, it is possible to flatten the list by passing a false value to the `list` option to ["send"](#send) or ["get"](#get). This means that when calling ($stats, $status) = $mpd->get( { list => 1 }, # This is the default [ 'stats', 'status' ] ); `$stats` and `$status` will each have a hash reference with the results of their respective commands; while when calling $combined_list = $mpd->get( { list => 0 }, [ [ search => artist => '"Tom Waits"' ], [ search => artist => '"David Bowie"' ], ]); `$combined_list` will hold an array reference with the combined results of both `search` commands. # ATTRIBUTES - **host** The host to connect to. Defaults to **localhost**. - **port** The port to connect to. Defaults to **6600**. - **password** The password to use to connect to the server. Defaults to undefined, which means to use no password. - **auto\_connect** If set to true, the constructor will block until the connection to the MPD server has been established. Defaults to false. # METHODS - **connect** Starts a connection to an MPD server, and returns a [Future](https://metacpan.org/pod/Future) that will be done when the connection is complete (or failed if the connection couldn't be established). If the client is already connected, this function will return an immediately completed Future. - **send** $future = $mpd->send( 'status' ); $future = $mpd->send( { parser => 'none' }, 'stats' ); $future = $mpd->send( search => artist => '"Tom Waits"' ); # Note the dumb string quoting $future = $mpd->send( { list => 0 }, [ [ search => artist => '"Tom Waits"' ], [ search => artist => '"David Bowie"' ], ]); $future = $mpd->send( \%options, 'stats', sub { ... } ); Asynchronously sends a command to an MPD server, and returns a [Future](https://metacpan.org/pod/Future). For information on what the value of this Future will be, please see the ["Server Responses"](#server-responses) section. This method can be called in a number of different ways: - If called with a single string, then that string will be sent as the command. - If called with a list, the list will be joined with spaces and sent as the command. - If called with an array reference, then the value of each of item in that array will be processed as above (with array references instead of plain lists). If sending multiple commands in one request, the `command_list...` commands can be left out and they will be automatically provided for you. An optional subroutine reference passed as the last argument will be set as the the `on_ready` of the Future, which will fire when there is a response from the server. A hash reference with additional options can be passed as the _first_ argument. Valid keys to use are: - **list** If set to false, results of command lists will be parsed as a single result. When set to true, each command in a command list is parsed independently. See ["Server Responses"](#server-responses) for more details. Defaults to true. This value is ignored when not sending a command list. - **parser** Specify the parser to use for the _entire_ response. Parser labels are MPD commands. If the requested parser is not found, the fallback `none` will be used. Alternatively, if the value itself is a code reference, then that will be called as $parser->( \@response_lines, \@command_names ); Where each element in `@response_lines` is a reference to the list of lines received after completing the corresponding element in `@command_names`. When setting `list` to false, `@response_lines` will have a single value, regardless of how many commands were sent. For ease of use, underscores in the final command name will be removed before sending to the server (unless the command name requires them). So $client->send( 'current_song' ); is entirely equivalent to $client->send( 'currentsong' ); - **get** Send a command in a blocking way. Internally calls **send** and immediately waits for the response. - **idle** Put the client in idle loop. This sends the `idle` command and registers an internal listener that will put the client back in idle mode after each server response. If called with a list of subsystem names, then the client will only listen to those subsystems. Otherwise, it will listen to all of them. If you are using this module for an event-based application (see below), this will configure the client to fire the events at the appropriate times. Returns a [Future](https://metacpan.org/pod/Future). Waiting on this future will block until the next call to **noidle** (see below). - **noidle** Cancel the client's idle mode. Sends an undefined value to the future created by **idle** and breaks the internal idle loop. - **version** Returns the version number of the protocol spoken by the server, and _not_ the version of the daemon. As this is provided by the server, this is `undef` until after a connection has been established with the `connect` method, or by setting `auto_connect` to true in the constructor. # EVENTS [Net::Async::MPD](https://metacpan.org/pod/Net::Async::MPD) does the [Role::EventEmitter](https://metacpan.org/pod/Role::EventEmitter) role, and inherits all the methods defined therein. Please refer to that module's documentation for information on how to register subscribers to the different events. ## Additional methods - **until** In addition to methods like `on` and `once`, provided by [Role::EventEmitter](https://metacpan.org/pod/Role::EventEmitter), this module also exposes an `until` method, which registers a listener until a certain condition is true, and then deregisters it. The method is called with two subroutine references. The first is subscribed as a regular listener, and the second is called only when the first one returns a true value. At that point, the entire set is unsubscribed. ## Event descriptions After calling **idle**, the client will be in idle mode, which means that any changes to the specified subsystems will trigger a signal. When the client receives this signal, it will fire an event named like the subsystem that fired it. The event will be fired with the client as the first argument, and the response from the server as the second argument. This can safely be ignored, since the server response will normally just hold the name of the subsystem that changed, which you already know. The existing events are the following, as defined by the MPD documentation. - **database** The song database has been changed after **update**. - **udpate** A database update has started or finished. If the database was modified during the update, the **database** event is also emitted. - **stored\_playlist** A stored playlist has been modified, renamed, created or deleted. - **playlist** The current playlist has been modified. - **player** The player has been started stopped or seeked. - **mixer** The volume has been changed. - **output** An audio output has been added, removed or modified (e.g. renamed, enabled or disabled) - **options** Options like repeat, random, crossfade, replay gain. - **partition** A partition was added, removed or changed. - **sticker** The sticker database has been modified. - **subscription** A client has subscribed or unsubscribed from a channel. - **message** A message was received on a channel this client is subscribed to. ## Other events - **close** The connection to the server has been closed. This event is not part of the MPD protocol, and is fired by [Net::Async::MPD](https://metacpan.org/pod/Net::Async::MPD) directly. - **error** The `error` event is inherited from [Role::EventEmitter](https://metacpan.org/pod/Role::EventEmitter). However, unlike stated in that module's documentation, and as explained in ["Error Handling"](#error-handling), users are _not_ required to register to this event for safe execution. # SEE ALSO - [AnyEvent::Net::MPD](https://metacpan.org/pod/AnyEvent::Net::MPD) A previous attempt at writing this distribution, based on [AnyEvent](https://metacpan.org/pod/AnyEvent). Although the design is largely the same, it is not as fully featured or as well tested as this one. - [Net::MPD](https://metacpan.org/pod/Net::MPD) A lightweight blocking MPD library. Has fewer dependencies than this one, but it does not curently support command lists. I took the idea of allowing for underscores in command names from this module. - [AnyEvent::Net::MPD](https://metacpan.org/pod/AnyEvent::Net::MPD) The original version of this module, which used [AnyEvent](https://metacpan.org/pod/AnyEvent). The interface on both of these modules is virtually identical. - [Audio::MPD](https://metacpan.org/pod/Audio::MPD) The first MPD library on CPAN. This one also blocks and is based on [Moose](https://metacpan.org/pod/Moose). However, it seems to be unmaintained at the moment. - [Dancer::Plugin::MPD](https://metacpan.org/pod/Dancer::Plugin::MPD) A [Dancer](https://metacpan.org/pod/Dancer) plugin to connect to MPD. Haven't really tried it, since I haven't used Dancer... - [POE::Component::Client::MPD](https://metacpan.org/pod/POE::Component::Client::MPD) A [POE](https://metacpan.org/pod/POE) component to connect to MPD. This uses Audio::MPD in the background. # AUTHOR - José Joaquín Atria # COPYRIGHT AND LICENSE This software is copyright (c) 2017-2018 by José Joaquín Atria. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. t000755001750001750 013403007516 14353 5ustar00jjatriajjatria000000000000Net-Async-MPD-0.005basic.t100644001750001750 45713403007516 15747 0ustar00jjatriajjatria000000000000Net-Async-MPD-0.005/tuse strict; use warnings; use Test::More; use Net::Async::MPD; ok my $mpd = Net::Async::MPD->new, 'constructor succeeds'; # Attributes can_ok $mpd, $_ foreach qw( version auto_connect state password host port ); # Methods can_ok $mpd, $_ foreach qw( send get idle noidle connect ); done_testing(); META.json100644001750001750 460513403007516 15676 0ustar00jjatriajjatria000000000000Net-Async-MPD-0.005{ "abstract" : "A non-blocking interface to MPD", "author" : [ "Jos\u00e9 Joaqu\u00edn Atria " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.012, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Net-Async-MPD", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0", "File::ShareDir::Install" : "0.06", "perl" : "5.010" } }, "develop" : { "requires" : { "Test::Pod" : "1.41" } }, "runtime" : { "requires" : { "Carp" : "0", "Future::Utils" : "0", "IO::Async" : "0.66", "IO::Async::Loop" : "0", "IO::Async::Stream" : "0", "IO::Socket::IP" : "0.39", "Log::Any" : "1.049", "Moo" : "2.003002", "MooX::HandlesVia" : "0.001008", "Role::EventEmitter" : "0.002", "Scalar::Util" : "0", "Types::Standard" : "1.000006", "namespace::clean" : "0", "perl" : "5.010", "strict" : "0", "warnings" : "0" } }, "test" : { "requires" : { "File::Share" : "0", "File::Which" : "0", "IO::Async::Timer::Periodic" : "0", "Net::EmptyPort" : "0", "Path::Tiny" : "0", "Scope::Guard" : "0", "Test::More" : "1.302078", "Try::Tiny" : "0.28", "Types::Path::Tiny" : "0", "lib" : "0", "perl" : "5.010" } } }, "provides" : { "Net::Async::MPD" : { "file" : "lib/Net/Async/MPD.pm", "version" : "0.005" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "jjatria at cpan.org", "web" : "https://gitlab.com/jjatria/Net-Async-MPD/issues" }, "repository" : { "type" : "git", "url" : "git://gitlab.com/jjatria/Net-Async-MPD.git", "web" : "https://gitlab.com/jjatria/Net-Async-MPD" } }, "version" : "0.005", "x_generated_by_perl" : "v5.26.2", "x_serialization_backend" : "Cpanel::JSON::XS version 4.02" } Makefile.PL100644001750001750 475513403007516 16235 0ustar00jjatriajjatria000000000000Net-Async-MPD-0.005# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.012. use strict; use warnings; use 5.010; use ExtUtils::MakeMaker; use File::ShareDir::Install; $File::ShareDir::Install::INCLUDE_DOTFILES = 1; $File::ShareDir::Install::INCLUDE_DOTDIRS = 1; install_share dist => "share"; my %WriteMakefileArgs = ( "ABSTRACT" => "A non-blocking interface to MPD", "AUTHOR" => "Jos\x{e9} Joaqu\x{ed}n Atria ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0, "File::ShareDir::Install" => "0.06" }, "DISTNAME" => "Net-Async-MPD", "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.010", "NAME" => "Net::Async::MPD", "PREREQ_PM" => { "Carp" => 0, "Future::Utils" => 0, "IO::Async" => "0.66", "IO::Async::Loop" => 0, "IO::Async::Stream" => 0, "IO::Socket::IP" => "0.39", "Log::Any" => "1.049", "Moo" => "2.003002", "MooX::HandlesVia" => "0.001008", "Role::EventEmitter" => "0.002", "Scalar::Util" => 0, "Types::Standard" => "1.000006", "namespace::clean" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "File::Share" => 0, "File::Which" => 0, "IO::Async::Timer::Periodic" => 0, "Net::EmptyPort" => 0, "Path::Tiny" => 0, "Scope::Guard" => 0, "Test::More" => "1.302078", "Try::Tiny" => "0.28", "Types::Path::Tiny" => 0, "lib" => 0 }, "VERSION" => "0.005", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Carp" => 0, "File::Share" => 0, "File::Which" => 0, "Future::Utils" => 0, "IO::Async" => "0.66", "IO::Async::Loop" => 0, "IO::Async::Stream" => 0, "IO::Async::Timer::Periodic" => 0, "IO::Socket::IP" => "0.39", "Log::Any" => "1.049", "Moo" => "2.003002", "MooX::HandlesVia" => "0.001008", "Net::EmptyPort" => 0, "Path::Tiny" => 0, "Role::EventEmitter" => "0.002", "Scalar::Util" => 0, "Scope::Guard" => 0, "Test::More" => "1.302078", "Try::Tiny" => "0.28", "Types::Path::Tiny" => 0, "Types::Standard" => "1.000006", "lib" => 0, "namespace::clean" => 0, "strict" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); { package MY; use File::ShareDir::Install qw(postamble); } share000755001750001750 013403007516 15212 5ustar00jjatriajjatria000000000000Net-Async-MPD-0.005mpd.pod100644001750001750 5205713403007516 16667 0ustar00jjatriajjatria000000000000Net-Async-MPD-0.005/share=pod =head1 test Blah =head1 Playback options =head2 consume consume {STATE} Sets consume state to C, C should be 0 or 1. When consume is activated, each song played is removed from playlist. =head2 crossfade crossfade {SECONDS} Sets crossfading between songs. =head2 mixrampdb mixrampdb {deciBels} Sets the threshold at which songs will be overlapped. Like crossfading but doesn't fade the track volume, just overlaps. The songs need to have MixRamp tags added by an external tool. 0dB is the normalized maximum volume so use negative values, I prefer -17dB. In the absence of mixramp tags crossfading will be used. See L =head2 mixrampdelay mixrampdelay {SECONDS} Additional time subtracted from the overlap calculated by mixrampdb. A value of "nan" disables MixRamp overlapping and falls back to crossfading. =head2 random random {STATE} Sets random state to C, C should be 0 or 1. =head2 repeat repeat {STATE} Sets repeat state to C, C should be 0 or 1. =head2 setvol setvol {VOL} Sets volume to C, the range of volume is 0-100. =head2 single single {STATE} Sets single state to C, C should be 0 or 1. When single is activated, playback is stopped after current song, or song is repeated if the 'repeat' mode is enabled. =head2 replay_gain_mode replay_gain_mode {MODE} Sets the replay gain mode. One of C, C, C, C. Changing the mode during playback may take several seconds, because the new settings does not affect the buffered data. This command triggers the C idle event. =head2 replay_gain_status replay_gain_status Prints replay gain options. Currently, only the variable C is returned. =head2 volume volume {CHANGE} Changes volume by amount C. B: C is deprecated, use C instead. =head1 Controlling playback =head2 next next Plays next song in the playlist. =head2 pause pause {PAUSE} Toggles pause/resumes playing, C is 0 or 1. B: The use of C command w/o the C argument is deprecated. =head2 play play [SONGPOS] Begins playing the playlist at song number C. =head2 playid playid [SONGID] Begins playing the playlist at song C. =head2 previous previous Plays previous song in the playlist. =head2 seek seek {SONGPOS} {TIME} Seeks to the position C