@ipcom/asterisk-ari 0.0.147 → 0.0.149
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/cjs/index.cjs
CHANGED
|
@@ -1206,57 +1206,36 @@ var ChannelInstance = class {
|
|
|
1206
1206
|
throw new Error("Media URL is required");
|
|
1207
1207
|
}
|
|
1208
1208
|
try {
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
throw new Error("Channel ID is not available");
|
|
1215
|
-
}
|
|
1216
|
-
} catch (error) {
|
|
1217
|
-
console.error("Failed to get channel details:", error);
|
|
1218
|
-
throw new Error("Could not initialize channel data");
|
|
1209
|
+
const mediaPath = options.media.replace("sound:", "");
|
|
1210
|
+
console.log("Formatted media path:", mediaPath);
|
|
1211
|
+
if (!this.channelData) {
|
|
1212
|
+
console.log("Fetching channel details...");
|
|
1213
|
+
this.channelData = await this.getDetails();
|
|
1219
1214
|
}
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
`/channels/${this.id}/play/${playbackInstance.id}`,
|
|
1229
|
-
options
|
|
1230
|
-
);
|
|
1231
|
-
console.log("Successfully initiated playback:", {
|
|
1232
|
-
channelId: this.id,
|
|
1233
|
-
playbackId: playbackInstance.id
|
|
1215
|
+
if (!this.channelData?.id) {
|
|
1216
|
+
throw new Error("Channel ID is not available");
|
|
1217
|
+
}
|
|
1218
|
+
console.log("Channel state:", this.channelData.state);
|
|
1219
|
+
const playback = this.client.Playback(playbackId || v4_default());
|
|
1220
|
+
return new Promise((resolve, reject) => {
|
|
1221
|
+
playback.once("PlaybackFinished", (event) => {
|
|
1222
|
+
console.log("Playback finished: ", event);
|
|
1234
1223
|
});
|
|
1235
|
-
|
|
1236
|
-
console.
|
|
1237
|
-
|
|
1224
|
+
this.baseClient.post(`/channels/${this.id}/play/${playback.id}`, options).then(() => {
|
|
1225
|
+
console.log("Playback request successful");
|
|
1226
|
+
resolve(playback);
|
|
1227
|
+
}).catch((error) => {
|
|
1228
|
+
console.error("Error starting playback:", error);
|
|
1229
|
+
reject(error);
|
|
1238
1230
|
});
|
|
1239
|
-
|
|
1240
|
-
console.warn("Playback was created but status could not be verified");
|
|
1241
|
-
} else {
|
|
1242
|
-
console.log("Playback status:", playbackStatus);
|
|
1243
|
-
}
|
|
1244
|
-
return playbackInstance;
|
|
1245
|
-
} catch (error) {
|
|
1246
|
-
const message = getErrorMessage(error);
|
|
1247
|
-
console.error(
|
|
1248
|
-
`Failed to start playback on channel ${this.id}:`,
|
|
1249
|
-
message
|
|
1250
|
-
);
|
|
1251
|
-
try {
|
|
1252
|
-
await playbackInstance.stop().catch();
|
|
1253
|
-
} catch {
|
|
1254
|
-
}
|
|
1255
|
-
throw new Error(`Failed to start playback: ${message}`);
|
|
1256
|
-
}
|
|
1231
|
+
});
|
|
1257
1232
|
} catch (error) {
|
|
1258
1233
|
const message = getErrorMessage(error);
|
|
1259
|
-
console.error(`Error playing media on channel ${this.id}:`,
|
|
1234
|
+
console.error(`Error playing media on channel ${this.id}:`, {
|
|
1235
|
+
error: message,
|
|
1236
|
+
options,
|
|
1237
|
+
channelState: this.channelData?.state
|
|
1238
|
+
});
|
|
1260
1239
|
throw new Error(`Failed to play media: ${message}`);
|
|
1261
1240
|
}
|
|
1262
1241
|
}
|