PlayAction

View as MarkdownOpen in Claude

Returned from call.play(). Tracks an active audio playback operation. Terminal states: finished, error.

Inherits all properties and methods from the base Action interface (controlId, isDone, completed, result, wait()).

Properties

No additional properties beyond the base Action interface.

Methods

Example

1import { RelayClient } from '@signalwire/sdk';
2
3const client = new RelayClient({
4 project: process.env.SIGNALWIRE_PROJECT_ID!,
5 token: process.env.SIGNALWIRE_TOKEN!,
6 contexts: ['default']
7});
8
9client.onCall(async (call) => {
10 await call.answer();
11 const action = await call.play(
12 [{ type: 'audio', url: 'https://example.com/hold-music.mp3' }],
13 { volume: -5.0, loop: 0 },
14 );
15
16 // Pause and resume playback
17 await action.pause();
18 await action.resume();
19
20 // Adjust volume
21 await action.volume(10.0);
22
23 // Stop playback
24 await action.stop();
25});
26
27await client.run();