question

sekar-perumal8558 avatar image
sekar-perumal8558 asked ·

C# Download MP3 recordings using SDK

Hi,

I am using the RingCentral SDK ( https://github.com/ringcentral/ringcentral-csharp) to download call recordings in my C# application.

I am able to make the call using recording id and I am getting the response.

If I save the response as .MP3 format, its not working it.




 var recordingRequest = new Request("/restapi/v1.0/account/~/recording/" + item.Recording.Id + "/content");
                            var recordingResponse = sdk.Platform.Get(recordingRequest);

                            byte[] byteArray = System.Convert.FromBase64String(recordingResponse.Body);

                            File.WriteAllBytes( item.Recording.Id + ".mp3", byteArray);



I am converting response text as byte array and storing it as MP3.

Is there anything wrong?

Could any one help me on this?
aaa
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered ·
Hi Sekar,

Why don't you try out the sample code from the SDK. I think recording content type is mp3 so I modified the code a little bit here.
var callLogs = await account.CallLog().List(queryParams);    // download a call recording  var callLog = callLogs.records[0];  var content = await account.Recording(callLog.recording.id).Content().Get();  
File.WriteAllBytes(callLog.recording.id + ".mp3", content.data);  
Hope this helps!

+ Phong
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Tyler Liu avatar image
Tyler Liu answered ·
Hi Sekar,

This SDK is what we recommend:  https://github.com/ringcentral/ringcentral-csharp-client

And sometimes the recording is *.wav instead of *mp3.
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

engineering-api-access8821 avatar image
engineering-api-access8821 answered ·
Hello Sekar,

  You can retrieve the recording meta data and check the contentType to determine if the recording is wave or mp3.  There is an account wide setting to change from the default mp3 to wave. The setting can only be changed by RingCentral. I have not been able to get much information on this setting.  I was told it's an account wide setting and that the recordings would be delivered in that format.  Its seems that this is incorrect as I am still getting both formats.  Unfortunately, my project I requires wav.

http://ringcentral-api-docs.readthedocs.io/en/latest/calllog_call-recordings/

 I hope this helps.
 
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

John Wang avatar image
John Wang answered ·
As mentioned by  Engineering API Access, the RingCentral endpoint can return a MP3 or a WAV file and you can distinguish this by examining the 'Content-Type' header.

A simple way to do this is check to see if 'Content-Type' header is 'audio/mpeg' in which case use '.mp3' extension, otherwise use '.wav' extension.

Here's a Ruby example:

https://github.com/grokify/ringcentral-sdk-ruby/blob/master/scripts/call-recording_download.rb#L48

ext = response_file.headers['Content-Type'].to_s == 'audio/mpeg' ? '.mp3' : '.wav'
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

developer2-twc9617 avatar image
developer2-twc9617 answered ·
Hi Sekar Perumal,

                                   I am also facing this issue. Kindly let me know how to resolve.
 Thanks.
1 comment
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.