Esempio n. 1
0
        /// <summary>
        /// called when a new cast session starts, and the media source was created and is ready.
        /// note that this is called before playback is started.
        /// </summary>
        /// <param name="transmitterName">display name of the transmitter</param>
        /// <param name="castPlayer">player that plays the cast stream</param>
        void OnCastStart(string transmitterName, UWPMediaPlayer castPlayer)
        {
            //show info
            Log("cast playback started");
            ShowToast(S.AppName, S.CastWelcome.ReplaceMap(new Dictionary <string, string>
            {
                { "{displayname}", miracastReceiver.DisplayName },
                { "{transmitter}", transmitterName }
            }, true));

            //init and show cast ui
            if (castUI == null)
            {
                castUI = new ImmersiveCastUI(S.AppName);
            }
            castUI.MoveToScreen(App.Config.CastDisplayId);
            castUI.SetCastSource(castPlayer);
            castUI.KeyPreview      = true;
            castUI.PreviewKeyDown += (s, e) =>
            {
                //end session with ESC
                if (e.KeyCode.Equals(Keys.Escape))
                {
                    miracastReceiver.EndCastSession();
                }
            };
            castUI.ShowImmersive();
        }
Esempio n. 2
0
        /// <summary>
        /// called when a new pin is available. Show this pin somewhere in your ui, and only hide it when either CastStart or CastEnd have been called.
        /// only called when RequirePinAuth is set to true.
        /// </summary>
        /// <param name="transmitterName">name of the transmitter to authentificate</param>
        /// <param name="pin">the pin that is available</param>
        void OnPinAvailable(string transmitterName, string pin)
        {
            Log($"new pin available: {pin}");

            //init cast ui and show pin
            if (castUI == null)
            {
                castUI = new ImmersiveCastUI(S.AppName);
            }
            castUI.MoveToScreen(App.Config.CastDisplayId);
            castUI.SetPin(S.CastPinMessage.ReplaceMap(new Dictionary <string, string>
            {
                { "{DisplayName}", miracastReceiver.DisplayName },
                { "{Transmitter}", transmitterName },
                { "{Pin}", pin }
            }));
            castUI.ShowImmersive();
        }