/// <summary>
        /// This is the click handler for the 'Default' button.  You would replace this with your own handler
        /// if you have a button or buttons on this page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        async private void startPlayToReceiver(object sender, RoutedEventArgs e)
        {
            Button b = sender as Button;

            if (b != null)
            {
                try
                {
                    InitialisePlayToReceiver();
                    startDMRButton.IsEnabled = false;
                    stopDMRButton.IsEnabled  = true;
                    await receiver.StartAsync();

                    IsReceiverStarted = true;
                    rootPage.NotifyUser("PlayToReceiver started", NotifyType.StatusMessage);
                }
                catch (Exception ecp)
                {
                    IsReceiverStarted        = false;
                    startDMRButton.IsEnabled = true;
                    stopDMRButton.IsEnabled  = false;
                    rootPage.NotifyUser("PlayToReceiver start failed, Error " + ecp.Message, NotifyType.ErrorMessage);
                }
            }
        }
        private async void HandleStartReceiverClicked(Object sender, RoutedEventArgs e)
        {
            try
            {
                if (_receiver == null)
                {
                    _receiver = new PlayToReceiver();
                }

                // Set the Properties that describe this receiver device
                _receiver.FriendlyName  = "Example Play To Receiver";
                _receiver.SupportsAudio = true;
                _receiver.SupportsVideo = true;
                _receiver.SupportsImage = true;

                // Subscribe to Play To Receiver events
                // Receive the request from the Play To source
                // and map it to how it should be handled in this app
                _receiver.SourceChangeRequested +=
                    HandleReceiverSourceChangeRequested;

                // Playback commands
                _receiver.PlayRequested  += HandleReceiverPlayRequested;
                _receiver.PauseRequested += HandleReceiverPauseRequested;
                _receiver.StopRequested  += HandleReceiverStopRequested;
                _receiver.PlaybackRateChangeRequested +=
                    HandleReceiverPlaybackRateChangeRequested;

                // Seek commands
                _receiver.CurrentTimeChangeRequested +=
                    HandleReceiverCurrentTimeChangeRequested;
                _receiver.TimeUpdateRequested +=
                    HandleReceiverTimeUpdateRequested;

                // Volume commands
                _receiver.VolumeChangeRequested +=
                    HandleReceiverVolumeChangeRequested;
                _receiver.MuteChangeRequested +=
                    HandleReceiverMuteChangeRequested;

                // Advertise the receiver on the local network
                // and start receiving commands
                await _receiver.StartAsync();

                // Use the DisplayRequest to prevent power-save
                // from interrupting the playback experience
                if (_displayRequest == null)
                {
                    _displayRequest = new DisplayRequest();
                    _displayRequest.RequestActive();
                }

                StatusText.Text = "'" + _receiver.FriendlyName + "' started.";
            }
            catch
            {
                _receiver       = null;
                StatusText.Text = "Failed to start receiver.";
            }
        }
예제 #3
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            dispatcher = Window.Current.CoreWindow.Dispatcher;
            manager    = PlayToManager.GetForCurrentView();
            manager.SourceRequested += manager_SourceRequested;

            receiver = new PlayToReceiver();
            receiver.PlayRequested               += receiver_PlayRequested;
            receiver.PauseRequested              += receiver_PauseRequested;
            receiver.StopRequested               += receiver_StopRequested;
            receiver.MuteChangeRequested         += receiver_MuteChangeRequested;
            receiver.VolumeChangeRequested       += receiver_VolumeChangeRequested;
            receiver.TimeUpdateRequested         += receiver_TimeUpdateRequested;
            receiver.CurrentTimeChangeRequested  += receiver_CurrentTimeChangeRequested;
            receiver.SourceChangeRequested       += receiver_SourceChangeRequested;
            receiver.PlaybackRateChangeRequested += receiver_PlaybackRateChangeRequested;
            receiver.SupportsAudio                = true;
            receiver.SupportsVideo                = true;
            receiver.SupportsImage                = true;

            receiver.FriendlyName = "Day #22 - PlayTo";

            await receiver.StartAsync();
        }