Skip to content
Draft
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
387 changes: 133 additions & 254 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ async function checkPlayer() {
}
```

#### Load, play, pause, stop, or seek
#### Prepare, play, pause, stop, or seek

The API uses discriminated unions with type guards for compile-time safety.
Only valid transport actions are available based on the player's status.
Expand All @@ -158,11 +158,11 @@ import {
getPlayer, PlaybackStatus, hasAction, AudioAction,
} from '@silvermine/tauri-plugin-audio';

async function loadAndPlay() {
async function prepareAndPlay() {
const player = await getPlayer();

if (player.status === PlaybackStatus.Idle) {
const { player: ready } = await player.load(
const { player: ready } = await player.prepare(
'https://example.com/song.mp3',
{
title: 'My Song',
Expand Down Expand Up @@ -260,13 +260,13 @@ the current `PlaybackStatus`:

| Status | Allowed Actions |
| --------- | ---------------------------- |
| Idle | load |
| Idle | prepare |
| Loading | stop |
| Ready | play, seek, stop |
| Playing | pause, seek, stop |
| Paused | play, seek, stop |
| Ended | play, seek, load, stop |
| Error | load |
| Ended | play, seek, prepare, stop |
| Error | prepare |

Settings (`setVolume`, `setMuted`, `setPlaybackRate`, `setLoop`),
`listen`, and `onTimeUpdate` are always available regardless of
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const COMMANDS: &[&str] = &[
"load",
"prepare",
"play",
"pause",
"stop",
Expand Down
4 changes: 2 additions & 2 deletions crates/audio-player/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ edition = "2024"
rust-version = "1.89"

[dependencies]
rodio = "0.19.0"
symphonia = { version = "0.5.5", default-features = false, features = ["mp3", "wav", "flac", "ogg", "isomp4", "aac", "pcm"] }
rodio = { version = "0.22.2", default-features = false, features = ["playback"] }
serde = { version = "1.0.228", features = ["derive"] }
symphonia = { version = "0.5.5", default-features = false, features = ["aac", "flac", "isomp4", "mp3", "ogg", "pcm", "vorbis", "wav"] }
thiserror = "2.0.17"
tracing = { version = "0.1.41", default-features = false, features = ["std", "log"] }
ureq = "2.12.1"
2 changes: 1 addition & 1 deletion crates/audio-player/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub struct TimeUpdate {
pub duration: f64,
}

/// Response from a transport action (load, play, pause, stop, seek).
/// Response from a transport action (prepare, play, pause, stop, seek).
///
/// Wraps the resulting [`PlayerState`] with status-expectation metadata so the
/// TypeScript layer can detect unexpected state transitions.
Expand Down
Loading