private IEnumerator PlayVideoCo() { var spinnerShown = false; while (!Player.isPrepared) { yield return(null); if (!spinnerShown) { ShowSpinner?.Invoke(); spinnerShown = true; } } Player.Play(); var totalTime = (Player.frameRate > 0) ? TimeSpan.FromSeconds(Player.frameCount / Player.frameRate) : TimeSpan.FromSeconds(0); var lastProgress = 0f; while (Player.isPlaying || PausedVideo) { // Update progress while playing if (Player.frameCount > 0) { var progress = ((float)Player.frame / (float)Player.frameCount); var currentTime = (Player.frameRate > 0) ? TimeSpan.FromSeconds(Player.frame / Player.frameRate) : TimeSpan.FromSeconds(0); VideoProgressUpdate?.Invoke(new VideoProgress { TotalTime = totalTime, CurrentTime = currentTime, Progress = progress }); if (ShortenInEditor && Application.isEditor && progress > 0.1f) { Player.Stop(); break; } lastProgress = progress; } yield return(null); } VideoDone?.Invoke(); }
public MainPageModel() { ShowAlert = ReactiveCommand.Create(() => { AlertMessage = "This is a sample Allert message!"; }); ShowAlertConfig = ReactiveCommand.Create(() => { Alert = new AlertConfig() { Message = "This is a sample Allert message!", Title = "This is a TestAlert", OkText = "Cool!" }; }); ShowToast = ReactiveCommand.Create(() => { ToastMessage = "This is a sample Toast message!"; }); ShowSpinner = ReactiveCommand.CreateFromObservable(() => Observable.Timer(TimeSpan.FromSeconds(5))); ShowSpinner.Subscribe(); ShowSpinnerDispose = ReactiveCommand.CreateFromObservable(() => Observable.Timer(TimeSpan.FromSeconds(5))); ShowSpinnerDispose.Subscribe(l => DisposeSpinner = true); }