Skip to content

Commit 7af46a0

Browse files
committed
fix: repair linux mediautil tests and sync media tutorial paths
- Fix stale mediautil test type refs after mpris->mediacontrol rename - Replace remaining internal/mpris tutorial paths with internal/mediacontrol - Keep docs and tests aligned with current package/key naming
1 parent ab1508d commit 7af46a0

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

docs/tutorials/17-media-player.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ app.MPRISWatcher = mediaWatcher
101101
### Linux (MPRIS)
102102

103103
```go
104-
// internal/mpris/mpris.go
104+
// internal/mediacontrol/mpris.go
105105
func (w *Watcher) Start() error {
106106
w.mu.Lock()
107107

@@ -134,7 +134,7 @@ func (w *Watcher) Start() error {
134134
### Windows (SMTC)
135135

136136
```go
137-
// internal/mpris/watcher_windows.go
137+
// internal/mediacontrol/watcher_windows.go
138138
func (w *Watcher) Start() error {
139139
w.mu.Lock()
140140
if w.running {
@@ -183,7 +183,7 @@ When a player is discovered, it is automatically selected if no player has been
183183
### Windows (SMTC)
184184

185185
```go
186-
// internal/mpris/watcher_windows.go
186+
// internal/mediacontrol/watcher_windows.go
187187
func (w *Watcher) pollSessions() {
188188
asyncOp, err := control.GlobalSystemMediaTransportControlsSessionManagerRequestAsync()
189189
if err != nil {
@@ -272,8 +272,8 @@ func (w *Watcher) publishToDataBus(state *PlayerState) {
272272

273273
keyPrefix := "mediacontrol_"
274274

275-
w.databus.SetSource(keyPrefix+"player_name", state.PlayerName, "", "mpris")
276-
w.databus.SetSource(keyPrefix+"identity", state.Identity, "", "mpris")
275+
w.databus.SetSource(keyPrefix+"player_name", state.PlayerName, "", "mediacontrol")
276+
w.databus.SetSource(keyPrefix+"identity", state.Identity, "", "mediacontrol")
277277
// ... title, artist, album, cover_url, progress, volume, capabilities
278278
}
279279
```
@@ -379,7 +379,7 @@ func serveMediaCoverArt(c *fiber.Ctx) error {
379379

380380
> **Key Pattern (Security):** The path is cleaned with `filepath.Clean()` and checked against allowed directory prefixes before reading. Linux allows `/tmp/`, `/var/tmp/`, and `~/.cache/`; Windows also allows `os.TempDir()`. This blocks directory traversal (`../../../etc/passwd`) while still allowing cover art cache files.
381381
382-
> **Concept (Go Build Tags):** OmniPanel-go uses build tags to compile platform-specific files. `internal/mpris/mpris.go` has `//go:build !windows` (Linux D-Bus), while `internal/mpris/watcher_windows.go` has `//go:build windows` (SMTC). Both expose the same `Watcher` API to the rest of the app.
382+
> **Concept (Go Build Tags):** OmniPanel-go uses build tags to compile platform-specific files. `internal/mediacontrol/mpris.go` has `//go:build !windows` (Linux D-Bus), while `internal/mediacontrol/watcher_windows.go` has `//go:build windows` (SMTC). Both expose the same `Watcher` API to the rest of the app.
383383
384384
## Media Integration in Distributed Deployments (Serve + Connect Mode)
385385

internal/mediautil/mediautil_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
type fakeWatcher struct {
1313
players []string
14-
states map[string]*mpris.PlayerState
14+
states map[string]*mediacontrol.PlayerState
1515
selected string
1616
setSelectedErr error
1717
callErr error
@@ -21,7 +21,7 @@ type fakeWatcher struct {
2121
}
2222

2323
func (f *fakeWatcher) ListPlayers() []string { return f.players }
24-
func (f *fakeWatcher) GetPlayerState(playerName string) *mpris.PlayerState {
24+
func (f *fakeWatcher) GetPlayerState(playerName string) *mediacontrol.PlayerState {
2525
return f.states[playerName]
2626
}
2727
func (f *fakeWatcher) GetSelectedPlayer() string { return f.selected }
@@ -53,7 +53,7 @@ func TestBuildPlayersResponse_Disabled(t *testing.T) {
5353
func TestBuildPlayersResponse_WithPlayersSkipsNilStates(t *testing.T) {
5454
w := &fakeWatcher{
5555
players: []string{"spotify", "vlc"},
56-
states: map[string]*mpris.PlayerState{
56+
states: map[string]*mediacontrol.PlayerState{
5757
"spotify": {
5858
PlayerName: "spotify",
5959
Identity: "Spotify",

0 commit comments

Comments
 (0)