private void Control_CurrentStateChanged(object sender, RoutedEventArgs e) { switch (Control.CurrentState) { case Windows.UI.Xaml.Media.MediaElementState.Playing: if (Element.KeepScreenOn) { _request.RequestActive(); } break; case Windows.UI.Xaml.Media.MediaElementState.Paused: case Windows.UI.Xaml.Media.MediaElementState.Stopped: case Windows.UI.Xaml.Media.MediaElementState.Closed: if (Element.KeepScreenOn) { _request.RequestRelease(); } break; } if (Element != null) { Element.CurrentState = (MediaElementState)((int)Control.CurrentState); //((IElementController)Element).SetValueFromRenderer(MediaElement.CurrentStateProperty, (MediaElementState)((int)Control.CurrentState)); Element.RaiseCurrentStateChanged(); } }
private void Tracking_Click(object sender, RoutedEventArgs e) { if (Tracking.IsChecked == true) { _geolocator.PositionChanged += OnPositionChanged; if (dispRequest == null) { if (ApplicationData.Current.LocalSettings.Values["KeepScreenOn"].ToString() == "1") { dispRequest = new Windows.System.Display.DisplayRequest(); dispRequest.RequestActive(); } } Clear.IsEnabled = false; } else { _geolocator.PositionChanged -= OnPositionChanged; if (dispRequest != null) { dispRequest.RequestRelease(); dispRequest = null; } Clear.IsEnabled = true; } }
async void deactivate() { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { if (dispRequest != null) { dispRequest.RequestRelease(); dispRequest = null; } }); }
private void ReleaseDisplay() { //must be same instance, so quit if it doesn't exist if (_displayRequest == null) { return; } //undo the request _displayRequest.RequestRelease(); }
private static void SetFalse() { if (_displayRequestRefCount > 0) { if (_appDisplayRequest == null) { _appDisplayRequest = new Windows.System.Display.DisplayRequest(); } _appDisplayRequest.RequestRelease(); _displayRequestRefCount--; } }
public static void ReleasePersistentDisplay() { //must be same instance, so quit if it doesn't exist if (_displayRequest == null) { return; } //undo the request _displayRequest.RequestRelease(); isAlreadyRequested = false; }
private async void ReleaseDisplay(StationLib.StationSocketListener SocketListener) { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { // your code should be here SocketListener.FailedConnectionCount = SocketListener.FailedConnectionCount; if (m_displayRequest == null) { return; } if (SocketListener.FailedConnectionCount <= 1) // noch keinen FailedCount { if (m_displayRequestCnt > 0) { //undo the request m_displayRequest.RequestRelease(); m_displayRequestCnt--; } } }); }
/// <summary> /// Once video playback has ended, release the display so Windows can handle the display state normally. /// </summary> public void ReleaseDisplay() { try { if (_displayRequest != null) { _displayRequest.RequestRelease(); } } catch (Exception e) { Serilog.Log.Information(e, "Error releasing display"); } }
public void ReleaseDisplay() { //must be same instance, so quit if it doesn't exist if (_displayRequest == null) { return; } if (_displayRequestCount > 0) { //undo the request _displayRequest.RequestRelease(); _displayRequestCount--; } }
private void DisplayRequestRequestActive(bool screenStaysOn) { if (CurrDisplayRequest == null) { CurrDisplayRequest = new Windows.System.Display.DisplayRequest(); } if (screenStaysOn) { CurrDisplayRequest.RequestActive(); } else { CurrDisplayRequest.RequestRelease(); } }
/// <summary> /// Deactivates a display request. /// </summary> public void RequestRelease() { #if WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP _request.RequestRelease(); #else s_refCount--; if (s_refCount == 0) { #if __ANDROID__ || __UNIFIED || WINDOWS_PHONE || WIN32 RequestReleaseImpl(); #endif } #endif }
private void OnKeepScreenOnChecked(object sender, RoutedEventArgs e) { if (CurrDisplayRequest == null) { CurrDisplayRequest = new Windows.System.Display.DisplayRequest(); } var ischeck = (sender as CheckBox).IsChecked.GetValueOrDefault(); if (ischeck) { CurrDisplayRequest.RequestActive(); } else { CurrDisplayRequest.RequestRelease(); } }
private async void StopReceiverButton_Click(object sender, RoutedEventArgs e) { try { // <SnippetStopAsync> if (receiver != null) { await receiver.StopAsync(); if (display != null) { display.RequestRelease(); } // Remove Play To Receiver events receiver.CurrentTimeChangeRequested -= receiver_CurrentTimeChangeRequested; receiver.MuteChangeRequested -= receiver_MuteChangeRequested; receiver.PauseRequested -= receiver_PauseRequested; receiver.PlaybackRateChangeRequested -= receiver_PlaybackRateChangeRequested; receiver.PlayRequested -= receiver_PlayRequested; receiver.SourceChangeRequested -= receiver_SourceChangeRequested; receiver.StopRequested -= receiver_StopRequested; receiver.TimeUpdateRequested -= receiver_TimeUpdateRequested; receiver.VolumeChangeRequested -= receiver_VolumeChangeRequested; // Remove MediaElement events VideoPlayer.Pause(); VideoPlayer.CurrentStateChanged -= VideoPlayer_CurrentStateChanged; VideoPlayer.MediaEnded -= VideoPlayer_MediaEnded; VideoPlayer.MediaFailed -= VideoPlayer_MediaFailed; VideoPlayer.MediaOpened -= VideoPlayer_MediaOpened; VideoPlayer.RateChanged -= VideoPlayer_RateChanged; VideoPlayer.SeekCompleted -= VideoPlayer_SeekCompleted; VideoPlayer.VolumeChanged -= VideoPlayer_VolumeChanged; StatusTextBlock.Text = "Stopped '" + receiver.FriendlyName + "'."; } // </SnippetStopAsync> } catch { StatusTextBlock.Text = "Failed to stop '" + receiver.FriendlyName + "'."; } }
protected override void OnNavigatedFrom(NavigationEventArgs e) { base.OnNavigatedFrom(e); NavigationService.StopService(); try { if (ScreenOnRequest != null) { ScreenOnRequest.RequestRelease(); } } catch { } try { DragOver -= OnDragOver; Drop -= OnDrop; } catch { } }
private async void DownloadLoop() { var displayRequest = new Windows.System.Display.DisplayRequest(); while (true) { await this.addSemaphore.WaitAsync(); var current = this.waitForDownloads.Dequeue(); await this.concurrentSemaphore.WaitAsync(); if (this.downloading.Count == 0) { displayRequest.RequestActive(); } this.downloading.Add(current); _ = Task.Run(() => current.StartDownload().ContinueWith(async t => { await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { this.concurrentSemaphore.Release(); this.downloading.Remove(current); this.allQueued.Remove(current); if (current.Finished.IsFaulted) { App.Current.NotifyError(current, current.Finished.Exception); } if (this.downloading.Count == 0) { displayRequest.RequestRelease(); } }); }));; } }
private void isDisplayRequest_Toggled(object sender, RoutedEventArgs e) //常亮按钮 { if (isDisplayRequest.IsOn) { //create the request instance if needed if (_displayRequest == null) { _displayRequest = new Windows.System.Display.DisplayRequest(); } //make request to put in active state _displayRequest.RequestActive(); } else { //must be same instance, so quit if it doesn't exist if (_displayRequest == null) { return; } //undo the request _displayRequest.RequestRelease(); } SaveSettings(); }
public void Dispose() { _displayRequest?.RequestRelease(); _displayRequest = null; }
private void RequestRelease_Click(object sender, RoutedEventArgs e) { _displayRequest.RequestRelease(); ActiveRequestCounter.Text = $"Currently active {(--_currentlyActive).ToString()} request"; }