🎉 live server seems to be working now

This commit is contained in:
2026-05-14 14:29:57 +02:00
commit d72e439fd9
181 changed files with 47406 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
# Basic Player Example
This example demonstrates how to create a simple Sendspin player that connects to a server and plays audio.
## What it does
- Connects to a Sendspin server
- Starts audio playback with automatic clock synchronization
- Displays metadata (title, artist, album) when received
- Shows playback status and statistics
- Supports volume control and mute
## Building
```bash
cd examples/basic-player
go build
```
## Running
Connect to a local server:
```bash
./basic-player
```
Connect to a specific server:
```bash
./basic-player -server 192.168.1.100:8927
```
Set custom player name and volume:
```bash
./basic-player -name "Living Room" -volume 80
```
## Command-line options
- `-server` - Server address (default: localhost:8927)
- `-name` - Player name (default: "Basic Player")
- `-volume` - Initial volume 0-100 (default: 80)
## Key features demonstrated
1. **Simple configuration** - Just specify server address and player name
2. **Callbacks** - Handle metadata, state changes, and errors
3. **Automatic sync** - Clock synchronization happens automatically
4. **Status monitoring** - Get real-time playback statistics
## Code highlights
```go
// Create player with configuration
config := sendspin.PlayerConfig{
ServerAddr: "localhost:8927",
PlayerName: "Living Room",
Volume: 80,
OnMetadata: func(meta sendspin.Metadata) {
log.Printf("Now playing: %s - %s", meta.Artist, meta.Title)
},
}
player, _ := sendspin.NewPlayer(config)
player.Connect()
player.Play()
```
## Next steps
- See `examples/custom-source/` for custom audio source implementation
- Check out the player CLI (root main.go) for a full-featured TUI player

View File

@@ -0,0 +1,88 @@
// ABOUTME: Basic Sendspin player example
// ABOUTME: Demonstrates how to connect to a server and play audio
package main
import (
"flag"
"fmt"
"log"
"os"
"os/signal"
"syscall"
"github.com/Sendspin/sendspin-go/pkg/sendspin"
)
func main() {
serverAddr := flag.String("server", "localhost:8927", "Sendspin server address")
playerName := flag.String("name", "Basic Player", "Player name")
volume := flag.Int("volume", 80, "Initial volume (0-100)")
flag.Parse()
config := sendspin.PlayerConfig{
ServerAddr: *serverAddr,
PlayerName: *playerName,
Volume: *volume,
BufferMs: 500, // 500ms playback buffer
DeviceInfo: sendspin.DeviceInfo{
ProductName: "Sendspin Example Player",
Manufacturer: "Sendspin",
SoftwareVersion: "1.0.0",
},
OnMetadata: func(meta sendspin.Metadata) {
log.Printf("Now playing: %s - %s (%s)", meta.Artist, meta.Title, meta.Album)
},
OnStateChange: func(state sendspin.PlayerState) {
log.Printf("State changed: %s (volume: %d, muted: %v)", state.State, state.Volume, state.Muted)
},
OnError: func(err error) {
log.Printf("Error: %v", err)
},
}
player, err := sendspin.NewPlayer(config)
if err != nil {
log.Fatalf("Failed to create player: %v", err)
}
defer player.Close()
log.Printf("Connecting to %s...", *serverAddr)
if err := player.Connect(); err != nil {
log.Fatalf("Failed to connect: %v", err)
}
log.Printf("Connected! Starting playback...")
if err := player.Play(); err != nil {
log.Fatalf("Failed to start playback: %v", err)
}
go func() {
for {
status := player.Status()
stats := player.Stats()
if status.Connected {
log.Printf("Status: %s | %s %dHz %dch %dbit | Buffer: %dms | RTT: %dμs",
status.State,
status.Codec,
status.SampleRate,
status.Channels,
status.BitDepth,
stats.BufferDepth,
stats.SyncRTT)
}
// Sleep for 5 seconds
select {
case <-make(chan struct{}):
}
}
}()
// Wait for interrupt signal
fmt.Println("\nPress Ctrl+C to stop playback")
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
<-sigChan
log.Printf("Shutting down...")
}