@ipcom/asterisk-ari 0.0.146 → 0.0.148
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js
CHANGED
|
@@ -1186,18 +1186,49 @@ var ChannelInstance = class {
|
|
|
1186
1186
|
throw new Error("Media URL is required");
|
|
1187
1187
|
}
|
|
1188
1188
|
try {
|
|
1189
|
+
const mediaPath = options.media.replace("sound:", "");
|
|
1190
|
+
console.log("Formatted media path:", mediaPath);
|
|
1189
1191
|
if (!this.channelData) {
|
|
1192
|
+
console.log("Fetching channel details...");
|
|
1190
1193
|
this.channelData = await this.getDetails();
|
|
1191
1194
|
}
|
|
1195
|
+
if (!this.channelData?.id) {
|
|
1196
|
+
throw new Error("Channel ID is not available");
|
|
1197
|
+
}
|
|
1198
|
+
console.log("Channel state:", this.channelData.state);
|
|
1192
1199
|
const playback = this.client.Playback(playbackId || v4_default());
|
|
1200
|
+
const payload = {
|
|
1201
|
+
media: options.media,
|
|
1202
|
+
...options.lang && { lang: options.lang }
|
|
1203
|
+
};
|
|
1204
|
+
console.log("Sending playback request:", {
|
|
1205
|
+
channelId: this.id,
|
|
1206
|
+
playbackId: playback.id,
|
|
1207
|
+
payload
|
|
1208
|
+
});
|
|
1193
1209
|
await this.baseClient.post(
|
|
1194
1210
|
`/channels/${this.id}/play/${playback.id}`,
|
|
1195
|
-
|
|
1211
|
+
payload
|
|
1196
1212
|
);
|
|
1213
|
+
try {
|
|
1214
|
+
const playbackStatus = await playback.get();
|
|
1215
|
+
if (playbackStatus.state !== "playing") {
|
|
1216
|
+
console.warn("Playback not in playing state:", playbackStatus);
|
|
1217
|
+
}
|
|
1218
|
+
playback.once("PlaybackFinished", (event) => {
|
|
1219
|
+
console.log("Playback finished", event);
|
|
1220
|
+
});
|
|
1221
|
+
} catch (error) {
|
|
1222
|
+
console.warn("Could not verify playback status:", error);
|
|
1223
|
+
}
|
|
1197
1224
|
return playback;
|
|
1198
1225
|
} catch (error) {
|
|
1199
1226
|
const message = getErrorMessage(error);
|
|
1200
|
-
console.error(`Error playing media on channel ${this.id}:`,
|
|
1227
|
+
console.error(`Error playing media on channel ${this.id}:`, {
|
|
1228
|
+
error: message,
|
|
1229
|
+
options,
|
|
1230
|
+
channelState: this.channelData?.state
|
|
1231
|
+
});
|
|
1201
1232
|
throw new Error(`Failed to play media: ${message}`);
|
|
1202
1233
|
}
|
|
1203
1234
|
}
|