Issue Description:
When streaming an MP3 file into a live Agora channel using the Media Pull RESTful API, the audio began repeating endlessly instead of playing only once. The developer configured the playback according to the Agora documentation but found that the file continued looping indefinitely.
Platform/SDK:
Agora Cloud Media Pull via RESTful API
Error Message (optional):
No specific error message returned; the issue is with unintended repeated playback of the media stream.
Step by Step Solution:
1. Verify the repeatTime Parameter:
Ensure that the JSON request body used to create the cloud media player includes the field "repeatTime": 1. This parameter defines the number of times the media source should repeat (1 means play once, 2 means twice, and so on).
json
{
"player": {
"streamUrl": "https://example.com/audio.mp3",
"channelName": "example-channel",
"uid": 12345,
"token": "YOUR_TOKEN",
"repeatTime": 1,
"name": "media-pull-test"
}
}
2. Check for Multiple Publishing UIDs:
Ensure that only one UID is joining the channel to publish the pulled media. Having multiple active publishers or repeated joins by different UIDs can cause overlapping or repeated audio streams.
3. Test Playback in Isolation:
Use test tools like Postman or the Agora Web Demo to verify expected playback behavior. Observe the audio session to confirm it stops automatically after one complete playback.
4. Monitor Session Activity:
In the Agora Console or your application logs, verify that only one playback session (UID) remains active during streaming.
Root Cause:
The repeated audio was not caused by a backend malfunction but by multiple UIDs publishing media in the same channel simultaneously. This led to perceived looping even though the repeatTime parameter was correctly set.
Prevention/Best Practice:
- Use a single dedicated UID for each media pull session.
- Always specify "repeatTime": 1 (or the desired repeat count) explicitly in the API request.
- Regularly review the list of active UIDs in your channel to ensure unused or duplicate publishers are disconnected.