Ejemplo n.º 1
0
        private void Cast_Click(object sender, RoutedEventArgs e)
        {
            //Retrieve the location of the casting button
            GeneralTransform transform = Cast.TransformToVisual(Window.Current.Content);
            Point            pt        = transform.TransformPoint(new Point(0, 0));

            //Show the picker above our casting button
            castingPicker.Show(new Rect(pt.X, pt.Y, Cast.ActualWidth, Cast.ActualHeight), Windows.UI.Popups.Placement.Above);
        }
        private void CustomMediaTransportControls_CastButton_Clicked(object sender, EventArgs e)
        {
            MenuFlyoutItem   castButton = sender as MenuFlyoutItem;
            GeneralTransform transform  = castButton.TransformToVisual(Window.Current.Content as UIElement);
            Point            pt         = transform.TransformPoint(new Point(0, 0));

            CastingDevicePicker castingPicker = new CastingDevicePicker();

            castingPicker.CastingDeviceSelected += CastingPicker_CastingDeviceSelected;
            castingPicker.Show(new Rect(pt.X, pt.Y, castButton.ActualWidth, castButton.ActualHeight));
        }
        private void castButton_Click(object sender, RoutedEventArgs e)
        {
            //Retrieve the location of the casting button
            GeneralTransform transform = castButton.TransformToVisual(Window.Current.Content as UIElement);
            Point            pt        = transform.TransformPoint(new Point(0, 0));

            //Show the picker above our casting button
            picker.Show(new Rect(pt.X, pt.Y, castButton.ActualWidth, castButton.ActualHeight), Windows.UI.Popups.Placement.Above);

            rootPage.NotifyUser("Cast Button Clicked", NotifyType.StatusMessage);
        }
        public void ShowCastingPicker()
        {
            if (CurrentPlayer == null)
            {
                return;
            }

            CastingDevicePicker picker = new CastingDevicePicker();

            picker.CastingDeviceSelected        += Picker_CastingDeviceSelected;
            picker.CastingDevicePickerDismissed += Picker_CastingDevicePickerDismissed;
            picker.Show(Window.Current.Bounds);
        }
Ejemplo n.º 5
0
        private void TransportControls_CastButtonClicked(object sender, EventArgs e)
        {
            //Pause Current Playback
            player.Pause();

            //Get the custom transport controls
            MediaTransportControlsWithCustomCastButton mtc = (MediaTransportControlsWithCustomCastButton)this.player.TransportControls;

            //Retrieve the location of the casting button
            GeneralTransform transform = mtc.CastButton.TransformToVisual(Window.Current.Content as UIElement);
            Point            pt        = transform.TransformPoint(new Point(0, 0));

            //Show the picker above our custom cast button
            picker.Show(new Rect(pt.X, pt.Y, mtc.CastButton.ActualWidth, mtc.CastButton.ActualHeight), Windows.UI.Popups.Placement.Above);
        }
Ejemplo n.º 6
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            player.Pause();
            InitialCastingPicker();
            if (connection == null)
            {
                // 從按下的 button 出現 picker 内容
                Button           btn       = sender as Button;
                GeneralTransform transform = btn.TransformToVisual(Window.Current.Content as UIElement);
                Point            pt        = transform.TransformPoint(new Point(0, 0));
                picker.Show(new Rect(pt.X, pt.Y, btn.ActualWidth, btn.ActualHeight), Windows.UI.Popups.Placement.Above);
            }
            else
            {
                // 關掉現在的連綫,要記得去掉 event 注冊以免發生 memory leak
                connection.ErrorOccurred -= Connection_ErrorOccurred;
                connection.StateChanged  -= Connection_StateChanged;
                await connection.DisconnectAsync();

                connection.Dispose();
                connection = null;
            }
        }