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

import { RelayClient } from '@signalwire/sdk';
const client = new RelayClient({
project: process.env.SIGNALWIRE_PROJECT_ID!,
token: process.env.SIGNALWIRE_API_TOKEN!,
contexts: ['default']
});
client.onCall(async (call) => {
await call.answer();
const action = await call.play(
[{ type: 'audio', url: 'https://example.com/hold-music.mp3' }],
{ volume: -5.0, loop: 0 },
);
// Pause and resume playback
await action.pause();
await action.resume();
// Adjust volume
await action.volume(10.0);
// Stop playback
await action.stop();
});
await client.run();