Ejemplo n.º 1
0
        bool DispatchDelayedImplementation(TimeSpan delay, Action action)
        {
            var timer = _dispatcherQueue.CreateTimer();

            timer.Interval = delay;
            timer.Tick    += OnTimerTick;
            timer.Start();
            return(true);

            void OnTimerTick(DispatcherQueueTimer sender, object args)
            {
                action();
                timer.Tick -= OnTimerTick;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="InAppNotification"/> class.
        /// </summary>
        public InAppNotification()
        {
            DefaultStyleKey = typeof(InAppNotification);

            _dispatcherQueue    = DispatcherQueue.GetForCurrentThread();
            _dismissTimer       = _dispatcherQueue.CreateTimer();
            _dismissTimer.Tick += DismissTimer_Tick;

            _stackedNotificationOptions = new List <NotificationOptions>();
        }
Ejemplo n.º 3
0
        public HohoemaPlaylistPlayer(
            IScheduler scheduler,
            IMessenger messenger,
            MediaPlayer mediaPlayer,
            VideoStreamingOriginOrchestrator videoStreamingOriginOrchestrator,
            PlayerSettings playerSettings,
            MediaPlayerSoundVolumeManager soundVolumeManager,
            RestoreNavigationManager restoreNavigationManager
            )
            : base(playerSettings, scheduler)
        {
            _messenger   = messenger;
            _mediaPlayer = mediaPlayer;
            _videoStreamingOriginOrchestrator = videoStreamingOriginOrchestrator;
            _playerSettings           = playerSettings;
            _soundVolumeManager       = soundVolumeManager;
            _restoreNavigationManager = restoreNavigationManager;
            _smtc            = SystemMediaTransportControls.GetForCurrentView();
            _dispatcherQueue = DispatcherQueue.GetForCurrentThread();

            _saveTimer             = _dispatcherQueue.CreateTimer();
            _saveTimer.Interval    = TimeSpan.FromSeconds(5);
            _saveTimer.IsRepeating = true;
            _saveTimer.Tick       += (s, _) =>
            {
                if (CurrentPlaylistItem == null)
                {
                    _saveTimer.Stop();
                    return;
                }

                //if (PrimaryViewPlayerManager.DisplayMode == PrimaryPlayerDisplayMode.Close) { return; }
                if (_mediaPlayer.PlaybackSession?.PlaybackState is not MediaPlaybackState.Playing)
                {
                    return;
                }

                _restoreNavigationManager.SetCurrentPlayerEntry(
                    new PlayerEntry()
                {
                    ContentId      = CurrentPlaylistItem.VideoId,
                    Position       = _mediaPlayer.PlaybackSession.Position,
                    PlaylistId     = CurrentPlaylistId?.Id,
                    PlaylistOrigin = CurrentPlaylistId?.Origin
                });
            };
        }
        private IDisposable ScheduleSlow <TState>(TState state, TimeSpan dueTime, Func <IScheduler, TState, IDisposable> action)
        {
            var d = new MultipleAssignmentDisposable();

            var timer = DispatcherQueue.CreateTimer();

            timer.Tick += (s, e) =>
            {
                var t = Interlocked.Exchange(ref timer, null);
                if (t != null)
                {
                    try
                    {
                        d.Disposable = action(this, state);
                    }
                    finally
                    {
                        t.Stop();
                        action = static (s, t) => Disposable.Empty;
                    }