Bloom.Edit.AudioRecording.HandleAudioDevices C# (CSharp) Method

HandleAudioDevices() public method

Returns a json string like {"devices":["microphone", "Logitech Headset"], "productName":"Logitech Headset", "genericName":"Headset"}, except that in practice currrently the generic and product names are the same and not as helpful as the above. Devices is a list of product names (of available recording devices), the productName and genericName refer to the current selection (or will be null, if no current device).
public HandleAudioDevices ( ApiRequest request ) : void
request Bloom.Api.ApiRequest
return void
        public void HandleAudioDevices(ApiRequest request)
        {
            #if __MonoCS__
            request.Failed("Not supported on Linux");
            #else
            var sb = new StringBuilder("{\"devices\":[");
            sb.Append(string.Join(",", RecordingDevice.Devices.Select(d => "\""+d.ProductName+"\"")));
            sb.Append("],\"productName\":");
            if (CurrentRecording.RecordingDevice != null)
                sb.Append("\"" + CurrentRecording.RecordingDevice.ProductName + "\"");
            else
                sb.Append("null");

            sb.Append(",\"genericName\":");
            if (CurrentRecording.RecordingDevice != null)
                sb.Append("\"" + CurrentRecording.RecordingDevice.GenericName + "\"");
            else
                sb.Append("null");

            sb.Append("}");
            request.ReplyWithJson(sb.ToString());
            #endif
        }