@ipcom/asterisk-ari 0.0.146 → 0.0.147
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,15 +1186,54 @@ var ChannelInstance = class {
|
|
|
1186
1186
|
throw new Error("Media URL is required");
|
|
1187
1187
|
}
|
|
1188
1188
|
try {
|
|
1189
|
-
|
|
1190
|
-
this.channelData
|
|
1189
|
+
try {
|
|
1190
|
+
if (!this.channelData) {
|
|
1191
|
+
this.channelData = await this.getDetails();
|
|
1192
|
+
}
|
|
1193
|
+
if (!this.channelData?.id) {
|
|
1194
|
+
throw new Error("Channel ID is not available");
|
|
1195
|
+
}
|
|
1196
|
+
} catch (error) {
|
|
1197
|
+
console.error("Failed to get channel details:", error);
|
|
1198
|
+
throw new Error("Could not initialize channel data");
|
|
1191
1199
|
}
|
|
1192
|
-
const
|
|
1193
|
-
|
|
1194
|
-
|
|
1200
|
+
const playbackInstance = this.client.Playback(playbackId || v4_default());
|
|
1201
|
+
console.log("Attempting to play media:", {
|
|
1202
|
+
channelId: this.id,
|
|
1203
|
+
playbackId: playbackInstance.id,
|
|
1195
1204
|
options
|
|
1196
|
-
);
|
|
1197
|
-
|
|
1205
|
+
});
|
|
1206
|
+
try {
|
|
1207
|
+
await this.baseClient.post(
|
|
1208
|
+
`/channels/${this.id}/play/${playbackInstance.id}`,
|
|
1209
|
+
options
|
|
1210
|
+
);
|
|
1211
|
+
console.log("Successfully initiated playback:", {
|
|
1212
|
+
channelId: this.id,
|
|
1213
|
+
playbackId: playbackInstance.id
|
|
1214
|
+
});
|
|
1215
|
+
const playbackStatus = await playbackInstance.get().catch((err) => {
|
|
1216
|
+
console.warn("Could not verify playback status:", err);
|
|
1217
|
+
return null;
|
|
1218
|
+
});
|
|
1219
|
+
if (!playbackStatus) {
|
|
1220
|
+
console.warn("Playback was created but status could not be verified");
|
|
1221
|
+
} else {
|
|
1222
|
+
console.log("Playback status:", playbackStatus);
|
|
1223
|
+
}
|
|
1224
|
+
return playbackInstance;
|
|
1225
|
+
} catch (error) {
|
|
1226
|
+
const message = getErrorMessage(error);
|
|
1227
|
+
console.error(
|
|
1228
|
+
`Failed to start playback on channel ${this.id}:`,
|
|
1229
|
+
message
|
|
1230
|
+
);
|
|
1231
|
+
try {
|
|
1232
|
+
await playbackInstance.stop().catch();
|
|
1233
|
+
} catch {
|
|
1234
|
+
}
|
|
1235
|
+
throw new Error(`Failed to start playback: ${message}`);
|
|
1236
|
+
}
|
|
1198
1237
|
} catch (error) {
|
|
1199
1238
|
const message = getErrorMessage(error);
|
|
1200
1239
|
console.error(`Error playing media on channel ${this.id}:`, message);
|