Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: play_card function with second_swipe support #2330

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions documentation/builders/card-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ using the alias option:
'0002':
# A RPC command using the alias definition with one arguments
# Here: Trigger music playback through the card interface
alias: play_card
args: [path/to/folder]
alias: play_folder
args:
- /path/to/folder
'0003':
# A RPC command using keyword arguments. Args and kwargs can also be mixed.
# Args and Kwargs translate directly into the function python call
# Some as in '0002' but using kwargs
alias: play_card
alias: play_album
kwargs:
folder: path/to/folder
albumartist: Some Artist Name
recursive: A song Name
```

> [!NOTE]
Expand Down
16 changes: 8 additions & 8 deletions documentation/builders/rpc-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@ The keyword ``method`` is optional. If needs to be used depends on the function
## Aliases

Not so complicated, right? It will get even easier. For common commands we have defined aliases. An alias simply maps
to a pre-defined RPC command, e.g. ``play_card`` maps to ``player.ctrl.play_card``.
to a pre-defined RPC command, e.g. ``play_folder`` maps to ``player.ctrl.play_folder``.

Instead of

```yml
package: player
plugin: ctrl
method: play_card
method: play_folder
args: [path/to/folder]
```

you can simply specify instead:

```yml
alias: play_card
alias: play_folder
args: [path/to/folder]
```

Expand All @@ -60,10 +60,10 @@ Using in alias is optional. But if the keyword is present in the configuration i
## Arguments

Arguments can be specified in similar fashion to Python function arguments: as positional arguments and / or
keyword arguments. Let's check out play_card, which is defined as:
keyword arguments. Let's check out play_folder, which is defined as:

```python
play_card(...) -> player.ctrl.play_card(folder: str, recursive: bool = False)
play_folder(...) -> player.ctrl.play_folder(folder: str, recursive: bool = False)
:noindex:

:param folder: Folder path relative to music library path
Expand All @@ -79,19 +79,19 @@ In the following examples, we will always use the alias for smaller configuratio
do exactly the same, but use different ways of specifying the command.

```yml
alias: play_card
alias: play_folder
args: [path/to/folder, True]
```

```yml
alias: play_card
alias: play_folder
args: [path/to/folder]
kwargs:
recursive: True
```

```yml
alias: play_card
alias: play_folder
kwargs:
folder: path/to/folder
recursive: True
Expand Down
42 changes: 0 additions & 42 deletions documentation/developers/docstring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@
* [replay](#components.playermpd.PlayerMPD.replay)
* [toggle](#components.playermpd.PlayerMPD.toggle)
* [replay\_if\_stopped](#components.playermpd.PlayerMPD.replay_if_stopped)
* [play\_card](#components.playermpd.PlayerMPD.play_card)
* [get\_single\_coverart](#components.playermpd.PlayerMPD.get_single_coverart)
* [get\_folder\_content](#components.playermpd.PlayerMPD.get_folder_content)
* [play\_folder](#components.playermpd.PlayerMPD.play_folder)
* [play\_album](#components.playermpd.PlayerMPD.play_album)
* [get\_volume](#components.playermpd.PlayerMPD.get_volume)
* [set\_volume](#components.playermpd.PlayerMPD.set_volume)
* [play\_card\_callbacks](#components.playermpd.play_card_callbacks)
* [components.playermpd.coverart\_cache\_manager](#components.playermpd.coverart_cache_manager)
* [components.rpc\_command\_alias](#components.rpc_command_alias)
* [components.synchronisation.rfidcards](#components.synchronisation.rfidcards)
Expand Down Expand Up @@ -852,11 +850,6 @@ Internal status
- last played folder: Needed to detect second swipe


Saving {'player_status': {'last_played_folder': 'TraumfaengerStarkeLieder', 'CURRENTSONGPOS': '0', 'CURRENTFILENAME': 'TraumfaengerStarkeLieder/01.mp3'},
'audio_folder_status':
{'TraumfaengerStarkeLieder': {'ELAPSED': '1.0', 'CURRENTFILENAME': 'TraumfaengerStarkeLieder/01.mp3', 'CURRENTSONGPOS': '0', 'PLAYSTATUS': 'stop', 'RESUME': 'OFF', 'SHUFFLE': 'OFF', 'LOOP': 'OFF', 'SINGLE': 'OFF'},
'Giraffenaffen': {'ELAPSED': '1.0', 'CURRENTFILENAME': 'TraumfaengerStarkeLieder/01.mp3', 'CURRENTSONGPOS': '0', 'PLAYSTATUS': 'play', 'RESUME': 'OFF', 'SHUFFLE': 'OFF', 'LOOP': 'OFF', 'SINGLE': 'OFF'}}}

References:
https://github.com/Mic92/python-mpd2
https://python-mpd2.readthedocs.io/en/latest/topics/commands.html
Expand Down Expand Up @@ -975,25 +968,6 @@ Re-start playing the last-played folder unless playlist is still playing
> but we keep it as it is specifically implemented in box 2.X


<a id="components.playermpd.PlayerMPD.play_card"></a>

#### play\_card

```python
@plugs.tag
def play_card(folder: str, recursive: bool = False)
```

Main entry point for trigger music playing from RFID reader. Decodes second swipe options before playing folder content

Checks for second (or multiple) trigger of the same folder and calls first swipe / second swipe action
accordingly.

**Arguments**:

- `folder`: Folder path relative to music library path
- `recursive`: Add folder recursively

<a id="components.playermpd.PlayerMPD.get_single_coverart"></a>

#### get\_single\_coverart
Expand Down Expand Up @@ -1089,22 +1063,6 @@ For volume control do not use directly, but use through the plugin 'volume',
as the user may have configured a volume control manager other than MPD


<a id="components.playermpd.play_card_callbacks"></a>

#### play\_card\_callbacks

Callback handler instance for play_card events.

- is executed when play_card function is called
States:
- See :class:`PlayCardState`
See :class:`PlayContentCallbacks`


<a id="components.playermpd.coverart_cache_manager"></a>

# components.playermpd.coverart\_cache\_manager

<a id="components.rpc_command_alias"></a>

# components.rpc\_command\_alias
Expand Down
4 changes: 2 additions & 2 deletions resources/default-settings/cards.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@
'T':
package: player
plugin: ctrl
method: play_card
method: play_folder
args: [path/to/music/folder]
'G':
alias: play_card
alias: play_folder
args: path/to/music/folder
'V+':
alias: change_volume
Expand Down
Loading
Loading