private void OnVideoPlayerPrepared(object sender, EventArgs e) { model.IsPrepared = true; SetBusy(false); model.Duration = TimeSpan.FromMilliseconds(nativePlayer.Duration); model.CurrentPosition = TimeSpan.Zero; model.DisplaySeekbar = true; Prepared?.Invoke(this, EventArgs.Empty); if (Mute) { model.IsMute = true; SetVolume(); } else { model.IsMute = false; SetVolume(); } if (AutoPlay) { model.IsPlaying = true; model.IsPrepared = true; nativePlayer.Play(); } }
private void BtnOK_Click(object sender, RoutedEventArgs e) { try { if (string.IsNullOrEmpty(txtVariable.Text)) { throw new Exception("You must set a variable name."); } if (txtVariable.Text.Contains(@"\s+")) { throw new Exception("Variable names cannot contain whitespace."); } if (Regex.IsMatch(txtVariable.Text, "var", RegexOptions.IgnoreCase) || Regex.IsMatch(txtVariable.Text, "string", RegexOptions.IgnoreCase) || Regex.IsMatch(txtVariable.Text, "stringbuilder", RegexOptions.IgnoreCase)) { throw new Exception("Invalid variable name."); } Prepared?.Invoke(this, new PrepareEventArgs { VariableName = txtVariable.Text, UseVar = chkImplicit.IsChecked != default ? (bool)chkImplicit.IsChecked : true, UseAppendLine = chkAppendLine.IsChecked != default ? (bool)chkAppendLine.IsChecked : false, LeftPadding = txtPadding.Text.Length, Cancelled = false, Object = (bool)rString.IsChecked ? OutputType.String : OutputType.StringBuilder }); DialogResult = true; Close(); }
/// <summary> /// ICADプロセス開始完了イベントを実行する /// </summary> /// <param name="sender">イベント呼び出し元オブジェクト</param> /// <param name="e">e</param> private void Command_ICADStarted(object sender, EventArgs e) { if (!(_iCadStartingForm == null || _iCadStartingForm.IsDisposed)) { _iCadStartingForm.Close(); } Prepared?.Invoke(this, new EventArgs()); }
public void PrepareAudio() { try { // 一开始应该是false的 _isPrepared = false; File dir = new File(_mDirString); if (!dir.Exists()) { dir.Mkdirs(); } string fileNameString = GeneralFileName(); using (var file = new File(dir, fileNameString)) { _mCurrentFilePathString = file.AbsolutePath; _mRecorder = new MediaRecorder(); // 设置输出文件 _mRecorder.SetOutputFile(file.AbsolutePath); } //设置meidaRecorder的音频源是麦克风 _mRecorder.SetAudioSource(AudioSource.Mic); // 设置文件音频的输出格式为amr _mRecorder.SetOutputFormat(OutputFormat.RawAmr); // 设置音频的编码格式为amr _mRecorder.SetAudioEncoder(AudioEncoder.AmrNb); //设置录音声道 _mRecorder.SetAudioChannels(1); //设置编码比特率 _mRecorder.SetAudioEncodingBitRate(1); //设置编码采样率 _mRecorder.SetAudioSamplingRate(8000); // 严格遵守google官方api给出的mediaRecorder的状态流程图 try { _mRecorder.Prepare(); } catch (IOException e) { Debug.WriteLine("录音未成功,请重试" + e.Message); } _mRecorder.Start(); // 准备结束 _isPrepared = true; // 已经准备好了,可以录制了 Prepared?.Invoke(this, new EventArgs()); } catch (IllegalStateException e) { e.PrintStackTrace(); } catch (IOException e) { e.PrintStackTrace(); } }
protected override void PrepareDbContext(TestDbContext context) { _scaffold.Run(context); Prepared?.Invoke(); }
internal void OnPrepare() { Prepared?.Invoke(this, EventArgs.Empty); }
protected void OnPrepared(Order order, ProcessState modificationType) { Prepared?.Invoke(this, new PreparedEventArgs(order, modificationType)); }
private void ProcessEvent() { while (m_Session != null) { try { m_Session.GetEvent(1, out IMFMediaEvent _event);//requests events and returns immediately _event.GetType(out MediaEventType eventtype); switch (eventtype) { case MediaEventType.MESessionEnded: State = PlaybackState.Stopped; Ended?.Invoke(this, new StoppedEventArgs()); break; case MediaEventType.MESessionPaused: Paused?.Invoke(this, new PausedEventArgs(GetPosition())); break; case MediaEventType.MESessionStopped: Stopped?.Invoke(this, new StoppedEventArgs()); break; case MediaEventType.MESessionStarted: Started.Invoke(this, new EventArgs()); break; case MediaEventType.MESessionTopologyStatus: //topology loaded Guid guidManager = typeof(IAudioSessionManager).GUID; (new MMDeviceEnumeratorComObject() as IMMDeviceEnumerator). GetDefaultAudioEndpoint(CoreAudioApi.DataFlow.Render, CoreAudioApi.Role.Multimedia, out IMMDevice endoint); endoint.Activate(ref guidManager, ClsCtx.ALL, IntPtr.Zero, out object _manager); IAudioSessionManager manager = _manager as IAudioSessionManager; manager.GetSimpleAudioVolume(Guid.Empty, 0, out m_Volume); m_Session.GetClock(out m_Clock); Guid guid_ratecontrol = typeof(IMFRateControl).GUID; Guid MF_RATE_CONTROL_SERVICE = Guid.Parse("866fa297-b802-4bf8-9dc9-5e3b6a9f53c9"); MediaFoundationInterop.MFGetService(m_Session, ref MF_RATE_CONTROL_SERVICE, ref guid_ratecontrol, out object _control); //gets rate control m_Rate = _control as IMFRateControl; IsPrepared = true; Prepared?.Invoke(this, new EventArgs()); break; } _event = null; } catch (COMException e) { if (e.HResult == MediaFoundationErrors.MF_E_NO_EVENTS_AVAILABLE) { continue; } else { throw e; } } catch (ThreadAbortException) { break; } } }
public void OnPrepare() { Prepared?.Invoke(this, EventArgs.Empty); }
public void Prepare(GameObject entity) { OnPrepare(entity); Prepared?.Invoke(this); }