/// <summary> /// Starts recording and save the specified file /// </summary> public void startRecordingAudio(string options) { try { MediaOptions mediaOptions; try { string[] optionsString = JSON.JsonHelper.Deserialize <string[]>(options); mediaOptions = new MediaOptions(); mediaOptions.Id = optionsString[0]; mediaOptions.Src = optionsString[1]; } catch (Exception) { DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); return; } if (mediaOptions != null) { Deployment.Current.Dispatcher.BeginInvoke(() => { try { if (!Media.players.ContainsKey(mediaOptions.Id)) { AudioPlayer audio = new AudioPlayer(this, mediaOptions.Id); Media.players.Add(mediaOptions.Id, audio); audio.startRecording(mediaOptions.Src); } DispatchCommandResult(new PluginResult(PluginResult.Status.OK)); } catch (Exception e) { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, e.Message)); } }); } else { DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); } } catch (Exception e) { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, e.Message)); } }
/// <summary> /// Starts recording and save the specified file /// </summary> public void startRecordingAudio(string options) { try { MediaOptions mediaOptions; try { string[] optionsString = JSON.JsonHelper.Deserialize<string[]>(options); mediaOptions = new MediaOptions(); mediaOptions.Id = optionsString[0]; mediaOptions.Src = optionsString[1]; } catch (Exception) { DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); return; } if (mediaOptions != null) { Deployment.Current.Dispatcher.BeginInvoke(() => { try { if (!Media.players.ContainsKey(mediaOptions.Id)) { AudioPlayer audio = new AudioPlayer(this, mediaOptions.Id); Media.players.Add(mediaOptions.Id, audio); audio.startRecording(mediaOptions.Src); } DispatchCommandResult(new PluginResult(PluginResult.Status.OK)); } catch (Exception e) { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, e.Message)); } }); } else { DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); } } catch (Exception e) { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, e.Message)); } }