Esempio n. 1
0
        private void _SMTC_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
        {
            switch (args.Property)
            {
            case SystemMediaTransportControlsProperty.SoundLevel:
                WriteChromeNativeMessageToSTDIO(new JProperty("Command", new JProperty("SystemMediaTransportControlsProperty", "SoundLevel")));
                break;

            default:
                break;
            }
        }
Esempio n. 2
0
 private void HandlePropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
     //if (sender.SoundLevel == SoundLevel.Muted)
     //{
     //    Pause();
     //    muted = true;
     //}
     //else if (muted && sender.SoundLevel != SoundLevel.Muted)
     //{
     //    Play();
     //    muted = false;
     //}
 }
Esempio n. 3
0
        void m_mediaControls_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
        {
            if (args.Property != SystemMediaTransportControlsProperty.SoundLevel)
            {
                return;
            }

            if (!IsInBackground())
            {
                // Dispatch call to the UI thread since the event may get fired on some other thread
                var ignore = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                {
                    await InitializeCaptureAsync();
                });
            }
            else
            {
                DisposeCapture();
            }
        }
Esempio n. 4
0
        private async void SystemMediaControls_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs e)
        {
            switch (e.Property)
            {
                case SystemMediaTransportControlsProperty.SoundLevel:
                    await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        if (sender.SoundLevel != Windows.Media.SoundLevel.Muted)
                        {
                            ScenarioInit();
                        }
                        else
                        {
                            ScenarioClose();
                        }
                    });
                    break;

                default:
                    break;
            }
        }
 private async void SystemMediaControls_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
     {
         if (args.Property == SystemMediaTransportControlsProperty.SoundLevel && Frame.CurrentSourcePageType == typeof(CameraView))
         {
             // Check to see if the app is being muted. If so, it is being minimized.
             if (sender.SoundLevel == SoundLevel.Muted)
             {
                 try
                 {
                     await CleanupCameraAsync();
                 }
                 catch { }
             }
             else if (!isInitialized)
             {
                 await InitializeCameraAsync();
             }
         }
     });
 }
Esempio n. 6
0
        private async void SystemMediaControls_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs e)
        {
            switch (e.Property)
            {
            case SystemMediaTransportControlsProperty.SoundLevel:
                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    if (sender.SoundLevel != Windows.Media.SoundLevel.Muted)
                    {
                        ScenarioInit();
                    }
                    else
                    {
                        ScenarioClose();
                    }
                });

                break;

            default:
                break;
            }
        }
 /// <summary>
 /// 系统音乐控制器属性改变的event handler
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 private void Smtc_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
 }
Esempio n. 8
0
 private async void OnMediaPropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
     if (args.Property == SystemMediaTransportControlsProperty.SoundLevel)
     {
         await TaskUtilities.RunOnDispatcherThreadAsync(async () =>
         {
             if (sender.SoundLevel != Windows.Media.SoundLevel.Muted)
             {
                 await StartPreviewAsync();
             }
             else
             {
                 await CloseAsync();
             }
         });
     }
 }
 void SystemMediaTransportControlsOnPropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
     Debug.WriteLine("BackgroundAudioRun.SystemMediaTransportControlsOnPropertyChanged() " + _id);
 }
Esempio n. 10
0
 /// <summary>
 ///     Fires when any SystemMediaTransportControl property is changed by system or user
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 private void systemmediatransportcontrol_PropertyChanged(SystemMediaTransportControls sender,
                                                          SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
     //TODO: If soundlevel turns to muted, app can choose to pause the music
 }
 private async void systemMediaControls_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         if (args.Property == SystemMediaTransportControlsProperty.SoundLevel)
         {
             // Check for the new Sound level
             switch (systemMediaControls.SoundLevel)
             {
                 case SoundLevel.Full:
                 case SoundLevel.Low:
                     // If we had paused due to system mute, then resume on unmute.
                     if (pausedDueToMute)
                     {
                         mediaPlayer.Play();
                         pausedDueToMute = false;
                     }
                     break;
                 case SoundLevel.Muted:
                     // We've been muted by the system. Pause playback to release resources.
                     if (mediaPlayer != null && mediaPlayer.PlaybackSession.PlaybackState == MediaPlaybackState.Playing)
                     {
                         mediaPlayer.Pause();
                         pausedDueToMute = true;
                     }
                     break;
             }
         }
     });
 }
        private async void SystemMediaControls_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs e)
        {
            switch (e.Property)
            {
                case SystemMediaTransportControlsProperty.SoundLevel:
                    // The callbacks for MediaControl_SoundLevelChanged and StopPreviewAsync may be invoked on threads other
                    // than the UI thread, so to ensure there's no synchronization issue, the Dispatcher is used here to
                    // ensure all operations run on the UI thread.
                    await dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
                        {
                            if (sender.SoundLevel == SoundLevel.Muted)
                            {
                                if (previewStarted)
                                {
                                    await mediaCaptureMgr.StopPreviewAsync();
                                    mediaCaptureMgr = null;
                                    previewStarted = false;
                                    VideoStream.Source = null;
                                }
                            }
                            else
                            {
                                if (!previewStarted)
                                {
                                    ShowSettings.Visibility = Visibility.Collapsed;
                                    StartPreview.IsEnabled = true;
                                }
                            }
                        });
                    break;

                default:
                    break;
            }
        }
Esempio n. 13
0
        private async void SystemMediaControls_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs e)
        {
            switch (e.Property)
            {
                case SystemMediaTransportControlsProperty.SoundLevel:
                    await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        if (sender.SoundLevel != Windows.Media.SoundLevel.Muted)
                        {
                            EnumerateWebcamsAsync();
                            m_rotHeight = CamView.Height;
                            m_rotWidth = CamView.Width;
                        }
                    });
                    break;

                default:
                    break;
            }
        }
 private async void systemMediaControls_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         if (args.Property == SystemMediaTransportControlsProperty.SoundLevel)
         {
             // Check for the new Sound level
             switch (systemMediaControls.SoundLevel)
             {
                 case SoundLevel.Full:
                     if (pausedDueToMute)
                     {
                         // If we previously paused due to being muted, resume. 
                         MyMediaElement.Play();
                     }
                     break;
                 case SoundLevel.Low:
                     // We're being ducked, take no action. 
                     break;
                 case SoundLevel.Muted:
                     if (MyMediaElement != null && MyMediaElement.CurrentState == MediaElementState.Playing)
                     {
                         // We've been muted by the system, pause to save our playback position. 
                         MyMediaElement.Pause();
                         pausedDueToMute = true;
                     }
                     break;
             }
         }
     });
 }
Esempio n. 15
0
 private void HandleSystemMediaTransportControlsPropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
     if (sender.SoundLevel == SoundLevel.Muted)
     {
         BackgroundMediaPlayer.Current.Pause();
     }
 }
Esempio n. 16
0
 private async void VideoPage_PropertyChanged(SystemMediaTransportControls ds, SystemMediaTransportControlsPropertyChangedEventArgs de)
 {
     if (ds.SoundLevel == SoundLevel.Muted)
     {
         await CameraHelper.StopPreview();
     }
     else
     {
         CameraHelper.InitCamera();
         //await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { BottomAppBar.IsEnabled = false; });
     }
 }
Esempio n. 17
0
 private void smtc_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
     // TODO: 如果音量调至静音,应用可以选择暂停音乐
 }
        private async void MainPage_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
        {
            if (args.Property != SystemMediaTransportControlsProperty.SoundLevel)
            {
                return;
            }

            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                if (sender.SoundLevel == SoundLevel.Muted)
                {
                    await FinalizeMediaCaptureAsync();
                }
                else
                {
                    await InitializeMediaCaptureAsync();
                }
            });
        }
Esempio n. 19
0
        private async void SystemMediaControls_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs e)
        {
            switch (e.Property)
            {
            case SystemMediaTransportControlsProperty.SoundLevel:
                // The callbacks for MediaControl_SoundLevelChanged and StopPreviewAsync may be invoked on threads other
                // than the UI thread, so to ensure there's no synchronization issue, the Dispatcher is used here to
                // ensure all operations run on the UI thread.
                await dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                {
                    if (sender.SoundLevel == SoundLevel.Muted)
                    {
                        if (previewStarted)
                        {
                            await mediaCaptureMgr.StopPreviewAsync();
                            mediaCaptureMgr    = null;
                            previewStarted     = false;
                            VideoStream.Source = null;
                        }
                    }
                    else
                    {
                        if (!previewStarted)
                        {
                            ShowSettings.Visibility = Visibility.Collapsed;
                            StartPreview.IsEnabled  = true;
                        }
                    }
                });

                break;

            default:
                break;
            }
        }
Esempio n. 20
0
 private async void OnMediaPropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
     if (args.Property == SystemMediaTransportControlsProperty.SoundLevel)
     {
         await TaskUtilities.RunOnDispatcherThreadAsync(async() =>
         {
             if (sender.SoundLevel != Windows.Media.SoundLevel.Muted)
             {
                 await StartPreviewAsync();
             }
             else
             {
                 await CloseAsync();
             }
         });
     }
 }
Esempio n. 21
0
        private void SMTC_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
        {

            //throw new NotImplementedException();
        }
        private async void systemMediaControls_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                if (args.Property == SystemMediaTransportControlsProperty.SoundLevel)
                {
                    // Check for the new Sound level
                    switch (systemMediaControls.SoundLevel)
                    {
                    case SoundLevel.Full:
                        if (pausedDueToMute)
                        {
                            // If we previously paused due to being muted, resume.
                            mediaPlayer.Play();
                        }
                        break;

                    case SoundLevel.Low:
                        // We're being ducked, take no action.
                        break;

                    case SoundLevel.Muted:
                        if (mediaPlayer != null && mediaPlayer.PlaybackSession.PlaybackState == MediaPlaybackState.Playing)
                        {
                            // We've been muted by the system, pause to save our playback position.
                            mediaPlayer.Pause();
                            pausedDueToMute = true;
                        }
                        break;
                    }
                }
            });
        }
Esempio n. 23
0
 void SystemMediaTransportControlsOnPropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
     Debug.WriteLine("BackgroundAudioRun.SystemMediaTransportControlsOnPropertyChanged() " + _id);
 }
Esempio n. 24
0
        private async void systemMediaControls_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                if (args.Property == SystemMediaTransportControlsProperty.SoundLevel)
                {
                    // Check for the new Sound level
                    switch (systemMediaControls.SoundLevel)
                    {
                    case SoundLevel.Full:
                    case SoundLevel.Low:
                        // If we had paused due to system mute, then resume on unmute.
                        if (pausedDueToMute)
                        {
                            mediaPlayer.Play();
                            pausedDueToMute = false;
                        }
                        break;

                    case SoundLevel.Muted:
                        // We've been muted by the system. Pause playback to release resources.
                        if (mediaPlayer != null && mediaPlayer.PlaybackSession.PlaybackState == MediaPlaybackState.Playing)
                        {
                            mediaPlayer.Pause();
                            pausedDueToMute = true;
                        }
                        break;
                    }
                }
            });
        }
Esempio n. 25
0
        void SystemMediaControls_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs e)
        {
            if (e.Property == SystemMediaTransportControlsProperty.SoundLevel)
            {
                var soundLevelState = sender.SoundLevel;

                DisplayStatus(GetTimeStampedMessage("App sound level is [" + SoundLevelToString(soundLevelState) + "]"));
                if (soundLevelState == SoundLevel.Muted)
                {
                    AppMuted();
                }
                else
                {
                    AppUnmuted();
                }
            }
        }
        void SystemMediaControls_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs e)
        {
            if (e.Property == SystemMediaTransportControlsProperty.SoundLevel)
            {
                var soundLevelState = sender.SoundLevel;

                DisplayStatus(GetTimeStampedMessage("App sound level is [" + SoundLevelToString(soundLevelState) + "]"));
                if (soundLevelState == SoundLevel.Muted)
                {
                    AppMuted();
                }
                else
                {
                    AppUnmuted();
                }
            }
        }
Esempio n. 27
0
        void m_mediaControls_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
        {
            if (args.Property != SystemMediaTransportControlsProperty.SoundLevel)
            {
                return;
            }

            // Dispatch call to the UI thread since the event may get fired on some other thread
            var ignore = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
            {
                if (!IsInBackground())
                {
                    await InitializeCaptureAsync();
                }
                else
                {
                    await DisposeCaptureAsync();
                }
            });
        }
 /// <summary>
 /// In the event of the app being minimized this method handles media property change events. If the app receives a mute
 /// notification, it is no longer in the foregroud.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 private async void SystemMediaControls_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
     {
         // Only handle this event if this page is currently being displayed
         if (args.Property == SystemMediaTransportControlsProperty.SoundLevel && Frame.CurrentSourcePageType == typeof(MainPage))
         {
             // Check to see if the app is being muted. If so, it is being minimized.
             // Otherwise if it is not initialized, it is being brought into focus.
             if (sender.SoundLevel == SoundLevel.Muted)
             {
                 await CleanupCameraAsync();
             }
             else if (!_isInitialized)
             {
                 await InitializeCameraAsync();
             }
         }
     });
 }
Esempio n. 29
0
 private void HandleSystemMediaTransportControlsPropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
     if (sender.SoundLevel == SoundLevel.Muted)
     {
         BackgroundMediaPlayer.Current.Pause();
     }
 }
 /// <summary>
 /// In the event of the app being minimized this method handles media property change events. If the app receives a mute
 /// notification, it is no longer in the foregroud.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 private async void SystemMediaControls_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
     {
         // Only handle this event if this page is currently being displayed
         if (args.Property == SystemMediaTransportControlsProperty.SoundLevel && Frame.CurrentSourcePageType == typeof(MainPage))
         {
             // Check to see if the app is being muted. If so, it is being minimized.
             // Otherwise if it is not initialized, it is being brought into focus.
             if (sender.SoundLevel == SoundLevel.Muted)
             {
                 await CleanupCameraAsync();
             }
             else if (!_isInitialized)
             {
                 await InitializeCameraAsync();
             }
         }
     });
 }
Esempio n. 31
0
 /// <summary>
 ///     Fires when any SystemMediaTransportControl property is changed by system or user
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 private void systemmediatransportcontrol_PropertyChanged(SystemMediaTransportControls sender,
     SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
     //TODO: If soundlevel turns to muted, app can choose to pause the music
 }
Esempio n. 32
0
        private async void _systemMediaControls_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
            {

                if (args.Property == SystemMediaTransportControlsProperty.SoundLevel && Frame.CurrentSourcePageType == typeof(MainPage))
                {

                    if (sender.SoundLevel == SoundLevel.Muted)
                    {
                        await CleanupCameraAsync();
                    }
                    else if (!_isInitialized)
                    {
                        await InitializeCameraAsync();
                    }
                }
            });
        }
        void systemMediaTransportControl_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
        {

        }
Esempio n. 34
0
 void systemControls_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
 }
 private void OnSystemMediaTransportControlPropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
     // TODO: Pause playback when muted
 }
Esempio n. 36
0
 private void Smtc_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
     if (sender.SoundLevel == SoundLevel.Muted && mediaPlayer.CurrentState == Playing)
     {
         logger.LogMessage("BackgroundAudio: Sounds muted - pausing playback.");
         mediaPlayer.Pause();
     }
 }
 /// <summary>
 /// Fires when any SystemMediaTransportControl property is changed by system or user
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 void smtc_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
     // If soundlevel turns to muted, app can choose to pause the music
 }
 private void OnSystemMediaTransportControlPropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
     // TODO: Pause playback when muted
 }
Esempio n. 39
0
 /// <summary>
 /// Fires when any SystemMediaTransportControl property is changed by system or user
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 void smtc_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
     // If soundlevel turns to muted, app can choose to pause the music
 }
 private void Smtc_PropertyChanged(SystemMediaTransportControls sender, SystemMediaTransportControlsPropertyChangedEventArgs args)
 {
     //TODO:Nothing
 }