Skip to content

Commit 30807e8

Browse files
committed
readme update
1 parent 1b222f2 commit 30807e8

1 file changed

Lines changed: 31 additions & 4 deletions

File tree

README.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
# SMTC4J
22
Simple Java Library for getting information about the current playback from the windows system media transport controls (SMTC).
33

4+
## Requirements
5+
- Java 21 or later
6+
- Windows 10 or later
7+
- GSON library for JSON parsing
8+
49
## Usage
510
Load the native library
611
```java
712
SMTC4J.load();
813
```
914

10-
Start the automatic update thread
15+
## Start the automatic update scheduler
1116

1217
```java
1318
long updateIntervalMillis = 500; // e.g., update every 500ms
14-
SMTC4J.startUpdateThread(updateIntervalMillis);
19+
SMTC4J.startUpdateScheduler(updateIntervalMillis);
1520
```
1621

17-
Access the cached information
22+
## Access the cached information
1823

1924
Media info (title, artist, album, duration, cover, source app):
2025
```java
@@ -28,4 +33,26 @@ Playback state (play/pause/stop code, position in seconds):
2833
PlaybackState playbackState = SMTC4J.getCachedPlaybackState();
2934
System.out.println("State code: " + playbackState.getStateCode());
3035
System.out.println("Position: " + playbackState.getPosition());
31-
```
36+
```
37+
38+
## Press media keys (PLAY, PAUSE, STOP, NEXT, PREVIOUS):
39+
40+
Using the scheduler:
41+
42+
```java
43+
SMTC4J.scheduleKeyPress(MediaKey.PLAY);
44+
```
45+
46+
Or directly:
47+
48+
```java
49+
SMTC4J.pressKey(MediaKey.NEXT);
50+
```
51+
52+
53+
# Important Notes
54+
This only works on Windows 10 and later versions, as it relies on the Windows SMTC API. <br>
55+
The the jars in the releases are built for x64 architecture. <br>
56+
If you you really need x86 support, you can build the native library from source using the provided C++ code. <br>
57+
If you try to call the native methods on a thread on which COM is already initialized, it may lead to crashes. <br>
58+
To avoid this, you should use the provided scheduler methods which handle threading and COM initialization internally.

0 commit comments

Comments
 (0)