Пример #1
0
        void ControlCurrentStateChanged(object sender, RoutedEventArgs e)
        {
            if (Element is null || Control is null)
            {
                return;
            }

            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;
            }

            Controller.CurrentState = FromWindowsMediaElementState(Control.CurrentState);
        }
Пример #2
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
            url = e.Parameter as string;
            if (dispRequest == null)
            {
                // 用户观看视频,需要保持屏幕的点亮状态
                dispRequest = new DisplayRequest();
                dispRequest.RequestActive(); // 激活显示请求
            }
            DisplayInformation.AutoRotationPreferences = (DisplayOrientations)5;
            string urls = await GetDiliVideoUri(url);

            if (urls != string.Empty)
            {
                mediaElment.Source = new Uri(urls);
                // PropertySet options = new PropertySet();
                // mediaElment.Stop();
                //FFmpegMSS = FFmpegInteropMSS.CreateFFmpegInteropMSSFromUri(urls, false, true, options);
                // MediaStreamSource mss = FFmpegMSS.GetMediaStreamSource();
                //Pass MediaStreamSource to Media Element
                //mediaElment.SetMediaStreamSource(mss);
            }
            else
            {
                await new MessageDialog("读取地址失败").ShowAsync();
            }
        }
Пример #3
0
        /// <summary>
        /// Starts the preview and adjusts it for for rotation and mirroring after making a request to keep the screen on and unlocks the UI.
        /// </summary>
        private async Task StartPreviewAsync()
        {
            // Prevent the device from sleeping while the preview is running.
            displayRequest.RequestActive();

            // Set the preview source in the UI and mirror it if necessary.
            PreviewControl.Source        = mediaCapture;
            PreviewControl.FlowDirection = mirroringPreview ? Windows.UI.Xaml.FlowDirection.RightToLeft : Windows.UI.Xaml.FlowDirection.LeftToRight;

            // Start the preview.
            try
            {
                await mediaCapture.StartPreviewAsync();

                isPreviewing = true;
            }
            catch (Exception ex)
            {
                rootPage.NotifyUser("Exception starting preview." + ex.Message, NotifyType.ErrorMessage);
            }

            // Initialize the preview to the current orientation.
            if (isPreviewing)
            {
                await SetPreviewRotationAsync();
            }
        }
Пример #4
0
        private async void StartPreviewAsync()
        {
            try
            {
                _mediaCapture = new MediaCapture();
                await _mediaCapture.InitializeAsync();

                CapPreview.Source = _mediaCapture;
                await _mediaCapture.StartPreviewAsync();

                _isPreviewing = true;

                _displayRequest.RequestActive();
                DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;
            }
            catch (UnauthorizedAccessException)
            {
                // This will be thrown if the user denied access to the camera in privacy settings
                System.Diagnostics.Debug.WriteLine("The app was denied access to the camera");
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("MediaCapture initialization failed. {0}", ex.Message);
            }
        }
Пример #5
0
        private async void InitializeAsync()
        {
            try
            {
                // Initialize Face API Client
                ViewModel.Initialize();

                // Setup Camera
                _cameraCapture = new MediaCapture();
                await _cameraCapture.InitializeAsync(new MediaCaptureInitializationSettings
                {
                    StreamingCaptureMode = StreamingCaptureMode.Video,
                    PhotoCaptureSource   = PhotoCaptureSource.VideoPreview,
                    AudioDeviceId        = String.Empty
                });

                _displayRequest.RequestActive();
                DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;
                cameraPreview.Source = _cameraCapture;

                await _cameraCapture.StartPreviewAsync();

                _isPreviewing = true;
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"0x{ex.HResult}: {ex.Message}");
            }
        }
Пример #6
0
        /// <summary>
        /// Start Preview
        /// </summary>
        /// <returns></returns>
        private async Task StartPreviewAsync()
        {
            try
            {
                _mediaCapture = new MediaCapture();
                await _mediaCapture.InitializeAsync();

                _displayRequest.RequestActive();
                DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;
            }
            catch (UnauthorizedAccessException)
            {
                // This will be thrown if the user denied access to the camera in privacy settings
                //textBlock.Text = "The app was denied access to the camera";
                return;
            }

            try
            {
                CamPreview.Source = _mediaCapture;
                await _mediaCapture.StartPreviewAsync();

                _isPreviewing = true;
            }
            catch (System.IO.FileLoadException)
            {
                //_mediaCapture.CaptureDeviceExclusiveControlStatusChanged += _mediaCapture_CaptureDeviceExclusiveControlStatusChanged;
            }
        }
Пример #7
0
        /// <summary>
        /// Starts the preview and adjusts it for for rotation and mirroring after making a request to keep the screen on and unlocks the UI
        /// </summary>
        /// <returns></returns>
        private async Task StartPreviewAsync()
        {
            Debug.WriteLine("StartPreviewAsync");

            // Prevent the device from sleeping while the preview is running
            _displayRequest.RequestActive();

            // Set the preview source in the UI and mirror it if necessary
            PreviewControl.Source        = _mediaCapture;
            PreviewControl.FlowDirection = _mirroringPreview ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;

            // Start the preview
            try
            {
                await _mediaCapture.StartPreviewAsync();

                _isPreviewing = true;
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception when starting the preview: {0}", ex.ToString());
            }

            // Initialize the preview to the current orientation
            if (_isPreviewing)
            {
                await SetPreviewRotationAsync();
            }

            // Enable / disable the button depending on the preview state
            GetPreviewFrameButton.IsEnabled = _isPreviewing;
        }
Пример #8
0
        async Task CameraInitializedAsync()
        {
            if (this.mediaCapture != null)
            {
                this.PreviewControl.Source = mediaCapture;
                displayRequest.RequestActive();
                previewProperties = mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview) as VideoEncodingProperties;
                await mediaCapture.StartPreviewAsync();

                int w = (int)previewProperties.Width, h = (int)previewProperties.Height;
                var buf = new byte[w * h * 3];

                reader = new BarcodeReader();

                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    if (this.mediaCapture != null)
                    {
                        _cameraState = CameraLoadedState.Loaded;
                        if (_scanStarted)
                        {
                            StartScanner();
                        }
                    }
                });
            }
        }
        private async Task StartPreviewAsync()
        {
            // Wrap in try catch because some devices may not have a camera and the user may deny access to the camera
            try
            {
                // Initialise capture device
                _mediaCapture = new MediaCapture();
                await _mediaCapture.InitializeAsync();

                // Connect the MediaCapture to the CaptureElement by setting the Source property
                PreviewControl.Source = _mediaCapture;
                await _mediaCapture.StartPreviewAsync();

                _isPreviewing = true;

                // Prevent the UI and the CaptureElement from rotating when the user changes the device orientation
                _displayRequest.RequestActive();
                DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;
            }
            catch (UnauthorizedAccessException)
            {
                // This will be thrown if the user denied access to the camera in privacy settings
                Debug.WriteLine("The app was denied access to the camera");
            }
            catch (Exception ex)
            {
                Debug.WriteLine("MediaCapture initialization failed: " + ex.Message);
            }
        }
Пример #10
0
        /// <summary>
        /// Starts the preview and adjusts it for for rotation and mirroring after making a request to keep the screen on and unlocks the UI
        /// </summary>
        /// <returns></returns>
        private async Task StartPreviewAsync()
        {
            Debug.WriteLine("StartPreviewAsync");

            // Prevent the device from sleeping while the preview is running
            _displayRequest.RequestActive();

            // Register to listen for media property changes
            _systemMediaControls.PropertyChanged += SystemMediaControls_PropertyChanged;

            // Set the preview source in the UI and mirror it if necessary
            PreviewControl.Source        = _mediaCapture;
            PreviewControl.FlowDirection = _mirroringPreview ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;

            // Start the preview
            await _mediaCapture.StartPreviewAsync();

            _isPreviewing = true;

            // Initialize the preview to the current orientation
            if (_isPreviewing)
            {
                await SetPreviewRotationAsync();
            }

            // Enable / disable the button depending on the preview state
            GetPreviewFrameButton.IsEnabled = _isPreviewing;
        }
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     ScannedCard = "";
     // Prevent screen timeout
     m_displayRequest.RequestActive();
     Application.Current.Suspending += App_Suspending;
 }
Пример #12
0
        private void LoadVipMovie(PlayerModel info)
        {
            try
            {
                pr_Load.Visibility = Visibility.Visible;
                DisplayInformation.AutoRotationPreferences = (DisplayOrientations)5;
                if (dispRequest == null)
                {
                    // 用户观看视频,需要保持屏幕的点亮状态
                    dispRequest = new DisplayRequest();
                    dispRequest.RequestActive(); // 激活显示请求
                }
                web.NavigateToString("");

                string playurl = "http://www.bilibili.com/html/html5player.html?cid=" + info.Mid + "&aid=" + info.Aid + "&as_wide=1&player_type=2&urlparam=module%3Dmovie&p=1&crossDomain=1&as_wide=1";
                web.Navigate(new Uri(playurl));
            }
            catch (Exception)
            {
                messShow.Show("读取错误", 3000);
            }
            finally
            {
                pr_Load.Visibility = Visibility.Collapsed;
            }
        }
Пример #13
0
        private async Task StartPreviewAsync()
        {
            try
            {
                _mediaCapture = new MediaCapture();
                await _mediaCapture.InitializeAsync();

                _displayRequest.RequestActive();
            }
            catch (UnauthorizedAccessException)
            {
                // This will be thrown if the user denied access to the camera in privacy settings
                await HelpersClass.ShowDialogAsync("The app was denied access to the camera");

                return;
            }

            try
            {
                PreviewControl.Source = _mediaCapture;
                await _mediaCapture.StartPreviewAsync();

                _isPreviewing = true;
            }
            catch (System.IO.FileLoadException)
            {
                //_mediaCapture.CaptureDeviceExclusiveControlStatusChanged += _mediaCapture_CaptureDeviceExclusiveControlStatusChanged;
            }
        }
Пример #14
0
        /// <summary>
        /// 开始预览
        /// </summary>
        /// <returns></returns>
        private async Task StartPreviewAsync()
        {
            Debug.WriteLine("StartPreviewAsync");

            //激活显示请求
            _displayRequest.RequestActive();
            captureElement.Source        = _mediaCapture;
            captureElement.FlowDirection = _mirroringPreview ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
            //开始预览
            try
            {
                await _mediaCapture.StartPreviewAsync();

                //捕捉的内容开始显示在屏幕上了
                _isPreviewing = true;
                //关闭闪光灯,如果不关闭闪关灯,当开始拍照时候就会开启闪光灯
                _mediaCapture.VideoDeviceController.FlashControl.AssistantLightEnabled = false;
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception when starting the preview: {0}", ex.ToString());
            }
            //是否开始捕捉内容了
            if (_isPreviewing)
            {
                await SetPreviewRotationAsync();
            }
            tip.Begin();
            PhotoHandle();
        }
Пример #15
0
        public static void StartDisplayRequest()
        {
            try
            {
                if (displayRequest == null)
                {
                    // This call creates an instance of the displayRequest object
                    displayRequest = new DisplayRequest();
                }
            }
            catch /*(Exception ex)*/
            {
                //rootPage.NotifyUser("Error Creating Display Request: " + ex.Message, NotifyType.ErrorMessage);
            }

            if (displayRequest != null)
            {
                try
                {
                    // This call activates a display-required request. If successful,
                    // the screen is guaranteed not to turn off automatically due to user inactivity.
                    displayRequest.RequestActive();
                    drCount += 1;
                    //rootPage.NotifyUser("Display request activated (" + drCount + ")", NotifyType.StatusMessage);
                }
                catch /*(Exception ex)*/
                {
                    //rootPage.NotifyUser("Error: " + ex.Message, NotifyType.ErrorMessage);
                }
            }
        }
        public ControlPageMaisto()
        {
            this.InitializeComponent();

            turn      = Turn.none;
            direction = Direction.none;

            accelerometer = App.accelerometer;
            bluetooth     = App.bluetooth;
            arduino       = App.arduino;

            if (accelerometer == null || bluetooth == null || arduino == null)
            {
                Frame.Navigate(typeof(MainPage));
                return;
            }

            startButton.IsEnabled      = true;
            stopButton.IsEnabled       = true;
            disconnectButton.IsEnabled = true;

            bluetooth.ConnectionLost += Bluetooth_ConnectionLost;

            keepScreenOnRequest = new DisplayRequest();
            keepScreenOnRequest.RequestActive();

            App.arduino.pinMode(FORWARD_CONTROL_PIN, PinMode.OUTPUT);
            App.arduino.pinMode(REVERSE_CONTROL_PIN, PinMode.OUTPUT);
            App.arduino.pinMode(LEFT_CONTROL_PIN, PinMode.OUTPUT);
            App.arduino.pinMode(RIGHT_CONTROL_PIN, PinMode.OUTPUT);
        }
Пример #17
0
        private void MediaElement_CurrentStateChanged(object sender, RoutedEventArgs e)
        {
            MediaElement mediaElement = sender as MediaElement;

            if (mediaElement != null && mediaElement.IsAudioOnly == false)
            {
                if (mediaElement.CurrentState == Windows.UI.Xaml.Media.MediaElementState.Playing)
                {
                    if (appDisplayRequest == null)
                    {
                        // This call creates an instance of the DisplayRequest object.
                        appDisplayRequest = new DisplayRequest();
                        appDisplayRequest.RequestActive();
                    }
                }
                else // CurrentState is Buffering, Closed, Opening, Paused, or Stopped.
                {
                    if (appDisplayRequest != null)
                    {
                        // Deactivate the display request and set the var to null.
                        appDisplayRequest.RequestRelease();
                        appDisplayRequest = null;
                    }
                }
            }
        }
Пример #18
0
        private async Task StartPreviewAsync()
        {
            try
            {
                mediaCapture = new MediaCapture();
                await mediaCapture.InitializeAsync();

                displayRequest.RequestActive();
                DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;
            }
            catch (UnauthorizedAccessException)
            {
                // This will be thrown if the user denied access to the camera in privacy settings
                MsgBox("Fail to InitializeAsync()", "Check First Try", "OK");
                //ShowMessageToUser("The app was denied access to the camera");
                return;
            }

            try
            {
                PreviewControl.Source = mediaCapture;
                await mediaCapture.StartPreviewAsync();

                isPreviewing = true;
            }
            catch (System.IO.FileLoadException)
            {
                mediaCapture.CaptureDeviceExclusiveControlStatusChanged += _mediaCapture_CaptureDeviceExclusiveControlStatusChanged;
            }
        }
Пример #19
0
        async Task StartPreviewAsync()
        {
            try
            {
                mediaCapture = new MediaCapture();
                await mediaCapture.InitializeAsync();

                displayRequest.RequestActive();

                if ("Windows.Mobile" == AnalyticsInfo.VersionInfo.DeviceFamily)
                {
                    mediaCapture.SetPreviewRotation(VideoRotation.Clockwise270Degrees);
                }

                // DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;
            }
            catch (UnauthorizedAccessException)
            {
                // This will be thrown if the user denied access to the camera in privacy settings
                // ShowMessageToUser("The app was denied access to the camera");
                return;
            }

            try
            {
                PreviewControl.Source = mediaCapture;
                await mediaCapture.StartPreviewAsync();

                isPreviewing = true;
            }
            catch (System.IO.FileLoadException)
            {
                mediaCapture.CaptureDeviceExclusiveControlStatusChanged += _mediaCapture_CaptureDeviceExclusiveControlStatusChanged;
            }
        }
Пример #20
0
        private async void Begin_button_Click(object sender, RoutedEventArgs e)
        {
            Comfirmation.Text = "";
            try
            {
                _mediaCapture = new MediaCapture();
                await _mediaCapture.InitializeAsync();

                PreviewControl.Source = _mediaCapture;
                await _mediaCapture.StartPreviewAsync();

                _isPreviewing = true;

                _displayRequest.RequestActive();
                DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait;
            }
            catch (UnauthorizedAccessException)
            {
                // This will be thrown if the user denied access to the camera in privacy settings
                System.Diagnostics.Debug.WriteLine("The app was denied access to the camera");
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("MediaCapture initialization failed. {0}", ex.Message);
            }
        }
        /// <summary>
        /// Starts the preview and adjusts it for for rotation and mirroring after making a request to keep the screen on
        /// </summary>
        /// <returns></returns>
        private async Task StartPreviewAsync()
        {
            // Prevent the device from sleeping while the preview is running
            _displayRequest.RequestActive();

            // Set the preview source in the UI and mirror it if necessary
            PreviewControl.Source        = _mediaCapture;
            PreviewControl.FlowDirection = _mirroringPreview ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;

            // Start the preview
            try
            {
                await _mediaCapture.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.VideoPreview, FindBestPreviewResolution());

                await _mediaCapture.StartPreviewAsync();

                _previewProperties = _mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception when starting the preview: {0}", ex.ToString());
            }

            // Initialize the preview to the current orientation
            if (_previewProperties != null)
            {
                _displayOrientation = _displayInformation.CurrentOrientation;

                await SetPreviewRotationAsync();
            }
        }
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Activate_Click(object sender, RoutedEventArgs e)
        {
            Error.Text = string.Empty;
            Button b = sender as Button;

            if (b != null)
            {
                try {
                    if (g_DisplayRequest == null)
                    {
                        // This call creates an instance of the displayRequest object
                        g_DisplayRequest = new DisplayRequest();
                    }
                } catch (Exception ex) {
                    rootPage.NotifyUser("Error Creating Display Request: " + ex.Message, NotifyType.ErrorMessage);
                }

                if (g_DisplayRequest != null)
                {
                    try {
                        // This call activates a display-required request. If successful,
                        // the screen is guaranteed not to turn off automatically due to user inactivity.
                        g_DisplayRequest.RequestActive();
                        drCount += 1;
                        rootPage.NotifyUser("Display request activated (" + drCount + ")", NotifyType.StatusMessage);
                    } catch (Exception ex) {
                        rootPage.NotifyUser("Error: " + ex.Message, NotifyType.ErrorMessage);
                    }
                }
            }
        }
Пример #23
0
        public MainPage()
        {
            this.InitializeComponent();

            // Start timer that periodically updates the diagnostics text at the bottom of the window
            activityUpdateTimer          = new DispatcherTimer();
            activityUpdateTimer.Tick    += ActivityUpdateTimer_Tick;
            activityUpdateTimer.Interval = new TimeSpan(0, 0, 0, 0, 250 /* milliseconds */);
            activityUpdateTimer.Start();

            // For convenience, save a pointer to logger module
            if (Application.Current as App != null)
            {
                logger = ((App)Application.Current).logger;
            }

            // Queue task to connect to device via BLE
            _ = Dispatcher.RunAsync(CoreDispatcherPriority.Low, DeviceConnect);

            // While we are running, don't blank out the screen or activate screen saver.
            // https://blogs.windows.com/windowsdeveloper/2016/05/24/how-to-prevent-screen-locks-in-your-uwp-apps/
            displayRequest = new DisplayRequest();
            displayRequest.RequestActive();

            // Listen for application events
            Application.Current.EnteredBackground += App_EnteredBackground;
            Application.Current.LeavingBackground += App_LeavingBackground;
            Application.Current.Suspending        += App_Suspending;
            Application.Current.Resuming          += App_Resuming;
        }
Пример #24
0
        public async Task StartPreviewAsync()
        {
            _mediaCapture   = new MediaCapture();
            _displayRequest = new DisplayRequest();

            try
            {
                await _mediaCapture.InitializeAsync();

                _displayRequest.RequestActive();
                DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;
            }
            catch (UnauthorizedAccessException ex)
            {
                _loggingService.Warning("The app was denied access to the camera. Details: {Ex}", ex);
                await _dialogService.ShowAsync("The app was denied access to the camera.");

                return;
            }

            try
            {
                _captureElement.Source = _mediaCapture;
                await _mediaCapture.StartPreviewAsync();

                _isPreviewing = true;
            }
            catch (System.IO.FileLoadException ex)
            {
                _loggingService.Warning("The camera preview can't be displayed, because another app has exclusive access. Details: {Ex}", ex);
                await _dialogService.ShowAsync("The camera preview can't be displayed, because another app has exclusive access.");
            }
        }
Пример #25
0
        private async void OnPlaybackStateChanged(MediaPlaybackSession sender, object args)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                switch (sender.PlaybackState)
                {
                case MediaPlaybackState.Opening:
                case MediaPlaybackState.Buffering:
                case MediaPlaybackState.Playing:
                    if (_request == null)
                    {
                        _request = new DisplayRequest();
                        _request.RequestActive();
                    }
                    break;

                default:
                    if (_request != null)
                    {
                        _request.RequestRelease();
                        _request = null;
                    }
                    break;
                }
            });
        }
Пример #26
0
        /// <summary>
        /// Starts the preview and adjusts it for for rotation and mirroring after making a request to keep the screen on and unlocks the UI
        /// </summary>
        /// <returns></returns>
        private async Task StartPreviewAsync()
        {
            Debug.WriteLine("StartPreviewAsync");

            // Prevent the device from sleeping while the preview is running
            _displayRequest.RequestActive();

            // Register to listen for media property changes
            _systemMediaControls.PropertyChanged += SystemMediaControls_PropertyChanged;

            // Set the preview source in the UI and mirror it if necessary
            if (Const.DISPLAY_PREVIEW)
            {
                PreviewControl.Source        = _mediaCapture;
                PreviewControl.FlowDirection = _mirroringPreview ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
            }
            else
            {
                PreviewControlFake               = new CaptureElement();
                PreviewControlFake.Source        = _mediaCapture;
                PreviewControlFake.FlowDirection = _mirroringPreview ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
            }

            // Start the preview
            await _mediaCapture.StartPreviewAsync();

            _isPreviewing = true;
        }
Пример #27
0
        public MainPage()
        {
            this.InitializeComponent();
            m_displayRequest.RequestActive();

            this.NavigationCacheMode = NavigationCacheMode.Required;
        }
        private void VideoPlayerOnCurrentStateChanged(object sender, RoutedEventArgs e)
        {
            // Check to hide the loading.
            if (_videoPlayer.CurrentState != MediaElementState.Opening)
            {
                // When we get to the state paused hide loading.
                if (_contentPanelBase.IsLoading)
                {
                    _contentPanelBase.FireOnLoading(false);
                }
            }

            // If we are playing request for the screen not to turn off.
            if (_videoPlayer.CurrentState == MediaElementState.Playing)
            {
                if (_displayRequest != null)
                {
                    return;
                }
                _displayRequest = new DisplayRequest();
                _displayRequest.RequestActive();
            }
            else
            {
                // If anything else happens and we have a current request remove it.
                if (_displayRequest == null)
                {
                    return;
                }
                _displayRequest.RequestRelease();
                _displayRequest = null;
            }
        }
Пример #29
0
 private async void PlaybackSession_PlaybackStateChanged(MediaPlaybackSession sender, object args)
 {
     if (sender is MediaPlaybackSession playbackSession && playbackSession.NaturalVideoHeight != 0)
     {
         if (playbackSession.PlaybackState == MediaPlaybackState.Playing)
         {
             if (!_isRequestActive)
             {
                 await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                 {
                     _displayRequest.RequestActive();
                     _isRequestActive = true;
                 });
             }
         }
         else
         {
             if (_isRequestActive)
             {
                 await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                 {
                     _displayRequest.RequestRelease();
                     _isRequestActive = false;
                 });
             }
         }
     }
 }
Пример #30
0
        //  private List<movie> movies;

        public MainPage()
        {
            this.InitializeComponent();
            TVs = TVManager.GetTVs();

            InitializeFrostedGlass(btl);
            InitializeFrostedGlass(GlassHost); //毛玻璃
            // movies = MovieManager.GetMovies();

            MediaPlayer             _mediaPlayer             = new MediaPlayer();
            MediaTimelineController _mediaTimelineController = new MediaTimelineController();

            var coreTitleBar = Windows.ApplicationModel.Core.CoreApplication.GetCurrentView().TitleBar;
            var appTitleBar  = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TitleBar;

            appTitleBar.ButtonBackgroundColor = Colors.Transparent;                   //透明标题栏
            // coreTitleBar.ExtendViewIntoTitleBar = true;
            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = false; //取消标题栏

            NavigationCacheMode = NavigationCacheMode.Enabled;
            //  SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;


            var displayRequest = new DisplayRequest();

            displayRequest.RequestActive();

            // Window.Current.SetTitleBar(btl); //应用标题栏
        }