internal void PlayHandler(CallEventParams.PlayParams playParams) { OnPlayStateChange?.Invoke(mAPI, this, playParams); switch (playParams.State) { case CallEventParams.PlayParams.PlayState.playing: OnPlayPlaying?.Invoke(mAPI, this, playParams); break; case CallEventParams.PlayParams.PlayState.error: OnPlayError?.Invoke(mAPI, this, playParams); break; case CallEventParams.PlayParams.PlayState.paused: OnPlayPaused?.Invoke(mAPI, this, playParams); break; case CallEventParams.PlayParams.PlayState.finished: OnPlayFinished?.Invoke(mAPI, this, playParams); break; default: break; } }
private async Task StartSimulator() { if (HasStarted) { return; } var fileName = Options.FileName; HasStarted = true; WantToStop = false; var noOfPeriods = Convert.ToInt32((int)Options.NoOfTimes / (int)Options.NoOfTimesPerPeriod); var cardPacks = CardPackFactory.Create(Options.NoOfCardPacks); PlayManager.CardPacks = cardPacks; for (int period = CurrentPeriod; period < noOfPeriods; period++) { for (int i = 0; i < (int)Options.NoOfTimesPerPeriod; i++) { var players = Players.Create(Options.NoOfPlayers); var data = await PlayManager.PlayAsync(players); DataRecorder.Record(new[] { data }); } await DataRecorder.SaveAsync(fileName, period == 0); CurrentPeriod = period; if (OnPeriodChange != null) { OnPeriodChange.Invoke(period, noOfPeriods); } if (WantToStop) { break; } } CurrentPeriod = (WantToStop) ? 0 : CurrentPeriod; if (OnPlayFinished != null && WantToStop == false) { OnPlayFinished.Invoke(Options.NoOfTimes, Options.NoOfTimesPerPeriod); } if (WantToStop && OnSimulatorStopped != null) { OnSimulatorStopped.Invoke(); } HasStarted = false; }
private void MediaPlayer_EndReached(object sender, Vlc.DotNet.Core.VlcMediaPlayerEndReachedEventArgs e) { //if (e.Exception != null) //{ // Log4NetHelper.InfoFormat("播放异常停止. cause by:{0}", e.Exception.ToString()); //} Stop(); //CloseFile(); if (OnPlayFinished != null) { OnPlayFinished.Invoke(); } else { Log4NetHelper.Info("no play finished handler..."); } }
void OnAudioPlayStopped(object sender, StoppedEventArgs e) { if (e.Exception != null) { Log4NetHelper.InfoFormat("播放异常停止. cause by:{0}", e.Exception.ToString()); } Stop(); CloseFile(); if (OnPlayFinished != null) { OnPlayFinished.Invoke(); } else { Log4NetHelper.Info("no play finished handler..."); } //Cleanup(); }