Skip to content

Commit ab8a6ae

Browse files
[#81] Playlist support
1 parent f40c02a commit ab8a6ae

14 files changed

Lines changed: 1005 additions & 5 deletions

File tree

doc/CLI.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Options:
1313
-c, --config CONFIG_FILE Set the path to the hrmp.conf file
1414
Default: $HOME/.hrmp/hrmp.conf
1515
-D, --device Set the device name
16+
-p, --playlist PLAYLIST Load files/directories from a playlist file (.hrmp)
1617
-R, --recursive Add files recursive of the directory
1718
-I, --sample-configuration Generate a sample configuration
1819
-m, --metadata Display metadata of the files
@@ -43,6 +44,21 @@ Select a non-default device for output
4344
hrmp -D "MyDAC" .
4445
```
4546

47+
## -p
48+
49+
Load files from a playlist file. The playlist is a plain text file (typically ending in `.hrmp`) with one entry per line:
50+
51+
* Relative file/directory path (relative to the playlist file directory)
52+
* Absolute file/directory path
53+
* `*` = all files in the playlist file directory
54+
* `**/*` = recursively add all files in the playlist file directory
55+
56+
If both a playlist and files are provided on the command line, the playlist entries are queued first.
57+
58+
```sh
59+
hrmp -p everlast.hrmp
60+
```
61+
4662
## -R
4763

4864
Play supported music files, and recurse through directories

doc/GETTING_STARTED.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Options:
1414
-c, --config CONFIG_FILE Set the path to the hrmp.conf file
1515
Default: $HOME/.hrmp/hrmp.conf
1616
-D, --device Set the device name
17+
-p, --playlist PLAYLIST Load files/directories from a playlist file (.hrmp)
1718
-R, --recursive Add files recursive of the directory
1819
-I, --sample-configuration Generate a sample configuration
1920
-m, --metadata Display metadata of the files

doc/man/hrmp.1.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ OPTIONS
2727
-D, --device
2828
Set the device name
2929

30+
-p, --playlist PLAYLIST
31+
Load files/directories from a playlist file (.hrmp)
32+
3033
-R, --recursive
3134
Add files recursive of the directory
3235

doc/manual/04-getting_started.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Options:
1616
-c, --config CONFIG_FILE Set the path to the hrmp.conf file
1717
Default: $HOME/.hrmp/hrmp.conf
1818
-D, --device Set the device name
19+
-p, --playlist PLAYLIST Load files/directories from a playlist file (.hrmp)
1920
-R, --recursive Add files recursive of the directory
2021
-I, --sample-configuration Generate a sample configuration
2122
-m, --metadata Display metadata of the files

doc/manual/05-cli.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Options:
1515
-c, --config CONFIG_FILE Set the path to the hrmp.conf file
1616
Default: $HOME/.hrmp/hrmp.conf
1717
-D, --device Set the device name
18+
-p, --playlist PLAYLIST Load files/directories from a playlist file (.hrmp)
1819
-R, --recursive Add files recursive of the directory
1920
-I, --sample-configuration Generate a sample configuration
2021
-m, --metadata Display metadata of the files
@@ -45,6 +46,21 @@ Select a non-default device for output
4546
hrmp -D "MyDAC" .
4647
```
4748

49+
## -p
50+
51+
Load files from a playlist file. The playlist is a plain text file (typically ending in `.hrmp`) with one entry per line:
52+
53+
* Relative file/directory path (relative to the playlist file directory)
54+
* Absolute file/directory path
55+
* `*` = all files in the playlist file directory
56+
* `**/*` = recursively add all files in the playlist file directory
57+
58+
If both a playlist and files are provided on the command line, the playlist entries are queued first.
59+
60+
```sh
61+
hrmp -p everlast.hrmp
62+
```
63+
4864
## -R
4965

5066
Play supported music files, and recurse through directories

doc/manual/06-ui.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ The toolbar is laid out from left to right as follows:
5959
- **Shuffle**: randomize the order of playlist entries (keeping the currently selected file as the first track).
6060
- The button icon changes to indicate the current mode (consecutive, repeat, shuffle).
6161

62+
10. **Add**
63+
- Opens a file chooser for selecting supported audio files and appends them to the playlist.
64+
65+
11. **Move up**
66+
- Moves the selected playlist entry one row up (no-op if it is already the first entry).
67+
68+
12. **Move down**
69+
- Moves the selected playlist entry one row down (no-op if it is already the last entry).
70+
71+
13. **Clear**
72+
- Stops hrmp if it is running and clears the playlist.
73+
6274
## Playlist View
6375

6476
You can add one file or multiple files at once, and the order shown reflects the playback order (subject to shuffle mode).
@@ -102,13 +114,23 @@ Below the file list there is a status panel showing the current file playing and
102114
- **Volume up**: Ctrl++
103115
- **Play mode** (Once/Repeat/Shuffle): Ctrl+M
104116
- **Add**: Ctrl+A
105-
- **Clear playlist**: Ctrl+L
117+
- **Move up**: Alt+Up
118+
- **Move down**: Alt+Down
119+
- **Clear**: Ctrl+L
106120

107121
These shortcuts complement the hrmp keyboard controls and work regardless of which widget currently has focus inside hrmp-ui.
108122

109123

110124
### File Menu
111125

126+
- **Load**
127+
- Opens a file chooser restricted to playlist files (`*.hrmp`).
128+
- Replaces the current playlist view with the contents of the selected `.hrmp` file.
129+
130+
- **Save**
131+
- Saves the current playlist view to a `.hrmp` file (one filename per line).
132+
- A filename is always required; the save dialog supports overwriting an existing file.
133+
112134
- **Quit**
113135
- Quits hrmp-ui.
114136
- If hrmp is still running, it is first asked to quit cleanly.

doc/manual/images/ui.png

193 Bytes
Loading

src/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#
22
# Add files for hrmp
33
#
4-
FILE(GLOB SOURCE_FILES "libhrmp/*.c")
5-
FILE(GLOB HEADER_FILES "include/*.h")
4+
FILE(GLOB SOURCE_FILES CONFIGURE_DEPENDS "libhrmp/*.c")
5+
FILE(GLOB HEADER_FILES CONFIGURE_DEPENDS "include/*.h")
66

77
set(SOURCES ${SOURCE_FILES} ${HEADER_FILES})
88

@@ -173,7 +173,7 @@ add_executable(hrmp-ui
173173
set_source_files_properties(hrmp-ui-resources.c PROPERTIES GENERATED TRUE)
174174

175175
target_include_directories(hrmp-ui PRIVATE ${GTK3_INCLUDE_DIRS})
176-
target_link_libraries(hrmp-ui PRIVATE ${GTK3_LIBRARIES})
176+
target_link_libraries(hrmp-ui PRIVATE hrmp ${GTK3_LIBRARIES})
177177
target_compile_options(hrmp-ui PRIVATE ${GTK3_CFLAGS_OTHER})
178178
target_compile_definitions(hrmp-ui PRIVATE HRMP_GTK_VERSION_STRING="${VERSION_STRING}")
179179

src/include/files.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ hrmp_file_metadata(char* f, struct file_metadata** fm);
8989
int
9090
hrmp_print_file_metadata(struct file_metadata* fm);
9191

92+
/**
93+
* Check if a file extension is supported by hrmp.
94+
* This only checks the filename extension.
95+
*
96+
* @param filename The filename
97+
* @return true if supported, otherwise false
98+
*/
99+
bool
100+
hrmp_file_is_supported(char* filename);
101+
92102
#ifdef __cplusplus
93103
}
94104
#endif

src/include/playlist.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (C) 2025 The HighResMusicPlayer community
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
#ifndef HRMP_PLAYLIST_H
19+
#define HRMP_PLAYLIST_H
20+
21+
#ifdef __cplusplus
22+
extern "C" {
23+
#endif
24+
25+
#include <list.h>
26+
27+
#include <stdbool.h>
28+
29+
/**
30+
* Load a playlist file (.hrmp) into an existing files list.
31+
*
32+
* Each non-empty line can be:
33+
* - Relative file/directory path (relative to the playlist file directory)
34+
* - Absolute file/directory path
35+
* - "*" to add all files in the playlist file directory
36+
* - recursive glob ("**" + "/" + "*")
37+
*
38+
* @param playlist_path Path to playlist file
39+
* @param files Target list to append files to
40+
* @param quiet If true, suppress warnings about missing files
41+
* @return 0 on success, otherwise 1
42+
*/
43+
int
44+
hrmp_playlist_load(const char* playlist_path, struct list* files, bool quiet);
45+
46+
#ifdef __cplusplus
47+
}
48+
#endif
49+
50+
#endif

0 commit comments

Comments
 (0)