| 1 |
Play Plugin |
| 2 |
=========== |
| 3 |
|
| 4 |
The ``play`` plugin allows you to pass the results of a query to a music player |
| 5 |
in the form of an m3u playlist or paths on the command line. |
| 6 |
|
| 7 |
Command Line Usage |
| 8 |
------------------ |
| 9 |
|
| 10 |
To use the ``play`` plugin, enable it in your configuration (see |
| 11 |
:ref:`using-plugins`). Then use it by invoking the ``beet play`` command with a |
| 12 |
query. The command will create a temporary m3u file and open it using an |
| 13 |
appropriate application. You can query albums instead of tracks using the ``-a`` |
| 14 |
option. |
| 15 |
|
| 16 |
By default, the playlist is opened using the ``open`` command on OS X, |
| 17 |
``xdg-open`` on other Unixes, and ``start`` on Windows. To configure the |
| 18 |
command, you can use a ``play:`` section in your configuration file: |
| 19 |
|
| 20 |
:: |
| 21 |
|
| 22 |
play: |
| 23 |
command: /Applications/VLC.app/Contents/MacOS/VLC |
| 24 |
|
| 25 |
You can also specify additional space-separated options to command (like you |
| 26 |
would on the command-line): |
| 27 |
|
| 28 |
:: |
| 29 |
|
| 30 |
play: |
| 31 |
command: /usr/bin/command --option1 --option2 some_other_option |
| 32 |
|
| 33 |
While playing you'll be able to interact with the player if it is a command-line |
| 34 |
oriented, and you'll get its output in real time. |
| 35 |
|
| 36 |
Interactive Usage |
| 37 |
----------------- |
| 38 |
|
| 39 |
The ``play`` plugin can also be invoked during an import. If enabled, the plugin |
| 40 |
adds a ``plaY`` option to the prompt, so pressing ``y`` will execute the |
| 41 |
configured command and play the items currently being imported. |
| 42 |
|
| 43 |
Once the configured command exits, you will be returned to the import decision |
| 44 |
prompt. If your player is configured to run in the background (in a |
| 45 |
client/server setup), the music will play until you choose to stop it, and the |
| 46 |
import operation continues immediately. |
| 47 |
|
| 48 |
Configuration |
| 49 |
------------- |
| 50 |
|
| 51 |
To configure the plugin, make a ``play:`` section in your configuration file. |
| 52 |
The available options are: |
| 53 |
|
| 54 |
- **command**: The command used to open the playlist. Default: ``open`` on OS X, |
| 55 |
``xdg-open`` on other Unixes and ``start`` on Windows. Insert ``$args`` to use |
| 56 |
the ``--args`` feature. |
| 57 |
- **relative_to**: If set, emit paths relative to this directory. Default: None. |
| 58 |
- **use_folders**: When using the ``-a`` option, the m3u will contain the paths |
| 59 |
to each track on the matched albums. Enable this option to store paths to |
| 60 |
folders instead. Default: ``no``. |
| 61 |
- **raw**: Instead of creating a temporary m3u playlist and then opening it, |
| 62 |
simply call the command with the paths returned by the query as arguments. |
| 63 |
Default: ``no``. |
| 64 |
- **warning_threshold**: Set the minimum number of files to play which will |
| 65 |
trigger a warning to be emitted. If set to ``no``, warning are never issued. |
| 66 |
Default: 100. |
| 67 |
- **bom**: Set whether or not a UTF-8 Byte Order Mark should be emitted into the |
| 68 |
m3u file. If you're using foobar2000 or Winamp, this is needed. Default: |
| 69 |
``no``. |
| 70 |
|
| 71 |
Optional Arguments |
| 72 |
------------------ |
| 73 |
|
| 74 |
The ``--args`` (or ``-A``) flag to the ``play`` command lets you specify |
| 75 |
additional arguments for your player command. Options are inserted after the |
| 76 |
configured ``command`` string and before the playlist filename. |
| 77 |
|
| 78 |
For example, if you have the plugin configured like this: |
| 79 |
|
| 80 |
:: |
| 81 |
|
| 82 |
play: |
| 83 |
command: mplayer -quiet |
| 84 |
|
| 85 |
and you occasionally want to shuffle the songs you play, you can type: |
| 86 |
|
| 87 |
:: |
| 88 |
|
| 89 |
$ beet play --args -shuffle |
| 90 |
|
| 91 |
to get beets to execute this command: |
| 92 |
|
| 93 |
:: |
| 94 |
|
| 95 |
mplayer -quiet -shuffle /path/to/playlist.m3u |
| 96 |
|
| 97 |
instead of the default. |
| 98 |
|
| 99 |
If you need to insert arguments somewhere other than the end of the ``command`` |
| 100 |
string, use ``$args`` to indicate where to insert them. For example: |
| 101 |
|
| 102 |
:: |
| 103 |
|
| 104 |
play: |
| 105 |
command: mpv $args --playlist |
| 106 |
|
| 107 |
indicates that you need to insert extra arguments before specifying the |
| 108 |
playlist. |
| 109 |
|
| 110 |
Some players require a different syntax. For example, with ``mpv`` the optional |
| 111 |
``$playlist`` variable can be used to match the syntax of the ``--playlist`` |
| 112 |
option: |
| 113 |
|
| 114 |
:: |
| 115 |
|
| 116 |
play: |
| 117 |
command: mpv $args --playlist=$playlist |
| 118 |
|
| 119 |
The ``--yes`` (or ``-y``) flag to the ``play`` command will skip the warning |
| 120 |
message if you choose to play more items than the **warning_threshold** value |
| 121 |
usually allows. |
| 122 |
|
| 123 |
The ``--randomize`` (or ``-R``) flag shuffles the order of playlist entries |
| 124 |
before passing it to the player: |
| 125 |
|
| 126 |
:: |
| 127 |
|
| 128 |
$ beet play --randomize my query |
| 129 |
|
| 130 |
Note on the Leakage of the Generated Playlists |
| 131 |
---------------------------------------------- |
| 132 |
|
| 133 |
Because the command that will open the generated ``.m3u`` files can be |
| 134 |
arbitrarily configured by the user, beets won't try to delete those files. For |
| 135 |
this reason, using this plugin will leave one or several playlist(s) in the |
| 136 |
directory selected to create temporary files (Most likely ``/tmp/`` on Unix-like |
| 137 |
systems. See tempfile.tempdir_ in the Python docs.). Leaking those playlists |
| 138 |
until they are externally wiped could be an issue for privacy or storage |
| 139 |
reasons. If this is the case for you, you might want to use the ``raw`` config |
| 140 |
option described above. |
| 141 |
|
| 142 |
.. _tempfile.tempdir: https://docs.python.org/3/library/tempfile.html#tempfile.tempdir |