예제 #1
0
        /// <summary>
        /// set the cast source that should render on the ui
        /// </summary>
        /// <param name="castPlayer">the player to render on the ui</param>
        public void SetCastSource(UWPMediaPlayer castPlayer)
        {
            //hide pin display
            lPin.Visible = false;

            //clear old mediaplayer element
            if (mediaPlayerElement != null)
            {
                Controls.Remove(mediaPlayerElement);
                mediaPlayerElement.Dispose();
            }

            //init new media player element
            mediaPlayerElement = new MediaPlayerElement()
            {
                Location  = new Point(0, 0),
                Margin    = new Padding(0),
                Dock      = DockStyle.Fill,
                BackColor = Color.Black,
                Stretch   = Microsoft.Toolkit.Win32.UI.Controls.Interop.WinRT.Stretch.UniformToFill
            };

            //set player to render to media element
            mediaPlayerElement.SetMediaPlayer(castPlayer);

            //add to window
            Controls.Add(mediaPlayerElement);
        }