Exemplo n.º 1
0
        private void OnCombinePickerClick(object sender, RoutedEventArgs e)
        {
            if (devicePicker == null)
            {
                devicePicker = new DevicePicker();

                // add casting
                devicePicker.Filter.SupportedDeviceSelectors.Add(CastingDevice.GetDeviceSelector(CastingPlaybackTypes.Video));

                // add dial
                devicePicker.Filter.SupportedDeviceSelectors.Add(DialDevice.GetDeviceSelector("castingsample"));

                // add projection
                devicePicker.Filter.SupportedDeviceSelectors.Add(ProjectionManager.GetDeviceSelector());

                devicePicker.DevicePickerDismissed   += DevicePicker_DevicePickerDismissed;
                devicePicker.DeviceSelected          += DevicePicker_DeviceSelected;
                devicePicker.DisconnectButtonClicked += DevicePicker_DisconnectButtonClicked;
            }

            player.Pause();

            // 從按下的 button 出現 picker 内容
            Button           btn       = sender as Button;
            GeneralTransform transform = btn.TransformToVisual(Window.Current.Content as UIElement);
            Point            pt        = transform.TransformPoint(new Point(0, 0));

            devicePicker.Show(new Rect(pt.X, pt.Y, btn.ActualWidth, btn.ActualHeight), Windows.UI.Popups.Placement.Above);
        }
Exemplo n.º 2
0
        private async void LoadAndDisplayScreens_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Use the device selector query of the ProjectionManager to list wired/wireless displays
                String projectorSelectorQuery = ProjectionManager.GetDeviceSelector();

                this.findAndProject_button.IsEnabled = false;

                // Clear the list box
                this.displayList_listview.Items.Clear();
                this.displayList_listview.Visibility = Visibility.Visible;

                rootPage.NotifyUser("Searching for devices...", NotifyType.StatusMessage);

                // Calling the device API to find devices based on the device query
                var outputDevices = await DeviceInformation.FindAllAsync(projectorSelectorQuery);

                // List found devices in the UI
                for (int i = 0; i < outputDevices.Count; i++)
                {
                    var device = outputDevices[i];
                    this.displayList_listview.Items.Add(device);
                }

                this.findAndProject_button.IsEnabled = true;
                rootPage.NotifyUser("Found devices are now listed.", NotifyType.StatusMessage);
            }
            catch (InvalidOperationException)
            {
                rootPage.NotifyUser("An error occured when querying and listing devices.", NotifyType.ErrorMessage);
            }
        }
Exemplo n.º 3
0
        //private async void ProjectionManager_ProjectionDisplayAvailableChanged(object sender, object e)
        //{
        //    await thisDispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
        //    {
        //        if (ProjectionManager.ProjectionDisplayAvailable)
        //        {
        //            StartProjecting(null);
        //        }
        //    });
        //}

        private async void transitionBtn_Click(object sender, RoutedEventArgs e)
        {
            // Use the device selector query of the ProjectionManager to list wired/wireless displays
            String projectorSelectorQuery = ProjectionManager.GetDeviceSelector();

            // Calling the device API to find devices based on the device query
            //DeviceInformationCollection outputDevices = await DeviceInformation.FindAllAsync(projectorSelectorQuery);
            //DeviceInformation selectedDevice = outputDevices[0];

            // Start projecting to the selected display
            StartProjecting(null);
        }
Exemplo n.º 4
0
        public Scenario06()
        {
            this.InitializeComponent();

            rootPage = MainPage.Current;

            //Subscribe to player events
            player.MediaOpened         += Player_MediaOpened;
            player.MediaFailed         += Player_MediaFailed;
            player.CurrentStateChanged += Player_CurrentStateChanged;

            // Get an Azure hosted video
            AzureDataProvider dataProvider = new AzureDataProvider();

            video = dataProvider.GetRandomVideo();

            //Set the source on the player
            rootPage.NotifyUser(string.Format("Opening '{0}'", video.Title), NotifyType.StatusMessage);
            this.player.Source    = video.VideoLink;
            this.LicenseText.Text = "License: " + video.License;

            //Configure the DIAL launch arguments for the current video
            this.dial_launch_args_textbox.Text = string.Format("v={0}&t=0&pairingCode=E4A8136D-BCD3-45F4-8E49-AE01E9A46B5F", video.Id);

            //Subscribe for the clicked event on the custom cast button
            ((MediaTransportControlsWithCustomCastButton)this.player.TransportControls).CastButtonClicked += TransportControls_CastButtonClicked;

            // Instantiate the Device Picker
            picker = new DevicePicker();

            //Hook up device selected event
            picker.DeviceSelected += Picker_DeviceSelected;

            //Hook up device disconnected event
            picker.DisconnectButtonClicked += Picker_DisconnectButtonClicked;

            //Hook up device disconnected event
            picker.DevicePickerDismissed += Picker_DevicePickerDismissed;

            //Add the DIAL Filter, so that the application only shows DIAL devices that have the application installed or advertise that they can install them.
            //BUG: picker.Filter.SupportedDeviceSelectors.Add(DialDevice.GetDeviceSelector(this.dial_appname_textbox.Text));
            picker.Filter.SupportedDeviceSelectors.Add("System.Devices.DevObjectType:=6 AND System.Devices.AepContainer.ProtocolIds:~~{0E261DE4-12F0-46E6-91BA-428607CCEF64} AND System.Devices.AepContainer.Categories:~~Multimedia.ApplicationLauncher.DIAL");

            //Add the CAST API Filter, so that the application only shows Miracast, Bluetooth, DLNA devices that can render the video
            // BUG: picker.Filter.SupportedDeviceSelectors.Add(await CastingDevice.GetDeviceSelectorFromCastingSourceAsync(player.GetAsCastingSource()));
            // BUG: picker.Filter.SupportedDeviceSelectors.Add(CastingDevice.GetDeviceSelector(CastingPlaybackTypes.Video));
            picker.Filter.SupportedDeviceSelectors.Add("System.Devices.InterfaceClassGuid:=\"{D0875FB4-2196-4c7a-A63D-E416ADDD60A1}\"" + " AND System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#True");

            //Add projection manager filter
            picker.Filter.SupportedDeviceSelectors.Add(ProjectionManager.GetDeviceSelector());

            pvb.ProjectionStopping += Pvb_ProjectionStopping;
        }
Exemplo n.º 5
0
        public async Task <IEnumerable <DeviceInformation> > GetProjectionDevices()
        {
            // List wired/wireless displays
            String projectorSelectorQuery = ProjectionManager.GetDeviceSelector();

            // Use device API to find devices based on the query
            var projectionDevices = await DeviceInformation.FindAllAsync(projectorSelectorQuery);

            var devices = new ObservableCollection <DeviceInformation>();

            foreach (var device in projectionDevices)
            {
                devices.Add(device);
            }

            return(devices);
        }
        public Scenario05()
        {
            this.InitializeComponent();

            rootPage = MainPage.Current;

            //Subscribe to player events
            player.MediaOpened         += Player_MediaOpened;
            player.MediaFailed         += Player_MediaFailed;
            player.CurrentStateChanged += Player_CurrentStateChanged;

            // Get an Azure hosted video
            AzureDataProvider dataProvider = new AzureDataProvider();

            video = dataProvider.GetRandomVideo();

            //Set the source on the player
            rootPage.NotifyUser(string.Format("Opening '{0}'", video.Title), NotifyType.StatusMessage);
            this.player.Source    = video.VideoLink;
            this.LicenseText.Text = "License: " + video.License;

            //Subscribe for the clicked event on the custom cast button
            ((MediaTransportControlsWithCustomCastButton)this.player.TransportControls).CastButtonClicked += TransportControls_CastButtonClicked;

            // Instantiate the Device Picker
            picker = new DevicePicker();

            // Get the device selecter for Miracast devices
            picker.Filter.SupportedDeviceSelectors.Add(ProjectionManager.GetDeviceSelector());

            //Hook up device selected event
            picker.DeviceSelected += Picker_DeviceSelected;

            //Hook up device disconnected event
            picker.DisconnectButtonClicked += Picker_DisconnectButtonClicked;

            //Hook up picker dismissed event
            picker.DevicePickerDismissed += Picker_DevicePickerDismissed;

            // Hook up the events that are received when projection is stoppped
            pvb.ProjectionStopping += Pvb_ProjectionStopping;
        }
Exemplo n.º 7
0
        public DisplayHandling(Action <string> onDeviceSelected)
        {
            // Get the device selector for Miracast devices
            _picker.Filter.SupportedDeviceSelectors.Add(ProjectionManager.GetDeviceSelector());

            //Hook up device selected event
            _picker.DeviceSelected += Picker_DeviceSelected;

            //Hook up picker dismissed event
            _picker.DevicePickerDismissed += Picker_DevicePickerDismissed;

            _onDeviceSelected = onDeviceSelected;

            // Hook up the events that are received when projection is stopped
            //pvb.ProjectionStopping += Pvb_ProjectionStopping;

            // load a setting that is local to the device
            ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            SelectedDeviceID = localSettings.Values[SelectedDeviceKey] as string;
        }
Exemplo n.º 8
0
        private async void watcherControlButton_Click(object sender, RoutedEventArgs e)
        {
            //Pause the video in the local player
            this.player.Pause();

            StopCurrentWatcher();

            this.castingDevicesList.Items.Clear();

            CustomDevicePickerFilter filter = new CustomDevicePickerFilter();

            //Add the CAST API Filter, so that the application only shows Miracast, Bluetooth, DLNA devices that can render the video
            //filter.SupportedDeviceSelectors.Add(await CastingDevice.GetDeviceSelectorFromCastingSourceAsync(this.player.GetAsCastingSource()));
            //Add the DIAL Filter, so that the application only shows DIAL devices that have the application installed or advertise that they can install them.
            filter.SupportedDeviceSelectors.Add(DialDevice.GetDeviceSelector(this.dial_appname_textbox.Text));
            filter.SupportedDeviceSelectors.Add(ProjectionManager.GetDeviceSelector());
            filter.SupportedDeviceSelectors.Add("System.Devices.InterfaceClassGuid:=\"{D0875FB4-2196-4c7a-A63D-E416ADDD60A1}\"" + " AND System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#True");

            //Create our watcher and have it find casting devices capable of video casting
            watcher = DeviceInformation.CreateWatcher(filter.ToString());

            //Register for watcher events
            watcher.Added   += Watcher_Added;
            watcher.Removed += Watcher_Removed;
            watcher.Stopped += Watcher_Stopped;
            watcher.Updated += Watcher_Updated;
            watcher.EnumerationCompleted += Watcher_EnumerationCompleted;

            //start the watcher
            watcher.Start();

            //update the UI to reflect the watcher's state
            rootPage.NotifyUser("Watcher has been started", NotifyType.StatusMessage);
            progressText.Text     = "Searching";
            progressRing.IsActive = true;
        }