public static FrameworkElement Render(AdaptiveMedia media, AdaptiveRenderContext context)
        {
            // If host doesn't support interactivity or no media source is provided
            // just return the poster image if present
            if (!context.Config.SupportsInteractivity || media.Sources.Count == 0)
            {
                return(GetPosterImage(media, context));
            }

            AdaptiveMediaSource mediaSource = GetMediaSource(media, context);

            if (mediaSource == null)
            {
                return(null);
            }

            // Main element to return
            var uiMedia = new Grid();

            #region Thumbnail button

            var mediaConfig = context.Config.Media;

            var uiThumbnailButton = new Grid
            {
                Name       = "thumbnailButton",
                Visibility = Visibility.Visible
            };

            /* Poster Image */

            // A poster container is necessary to handle background color and opacity mask
            // in case poster image is not found or does not exist
            var uiPosterContainer = new Grid()
            {
                Background = _controlBackgroundColor,
            };

            Image uiPosterImage = GetPosterImage(media, context);
            if (uiPosterImage != null)
            {
                uiPosterContainer.Children.Add(uiPosterImage);
            }

            uiThumbnailButton.Children.Add(uiPosterContainer);

            // Play button
            var uiPlayButton = RenderThumbnailPlayButton(context);
            uiThumbnailButton.Children.Add(uiPlayButton);

            // Mouse hover handlers to signify playable media element
            uiThumbnailButton.MouseEnter += (sender, e) =>
            {
                uiPosterContainer.OpacityMask = _controlBackgroundColor;
            };
            uiThumbnailButton.MouseLeave += (sender, e) =>
            {
                uiPosterContainer.OpacityMask = null;
            };

            #endregion

            uiMedia.Children.Add(uiThumbnailButton);

            // Inline playback is possible only when inline playback is allowed by the host and the chosen media source is not https
            bool isInlinePlaybackPossible = mediaConfig.AllowInlinePlayback && context.Config.ResolveFinalAbsoluteUri(mediaSource.Url).Scheme != "https";

            FrameworkElement uiMediaPlayer = null;
            if (isInlinePlaybackPossible)
            {
                // Media player is only created if inline playback is allowed
                uiMediaPlayer            = RenderMediaPlayer(context, mediaSource, uiMedia);
                uiMediaPlayer.Visibility = Visibility.Collapsed;

                uiMedia.Children.Add(uiMediaPlayer);
            }

            // Play the media
            uiThumbnailButton.MouseUp += (sender, e) =>
            {
                if (isInlinePlaybackPossible)
                {
                    if (IsAudio(mediaSource) && uiPosterImage != null)
                    {
                        // If media is audio, keep only the poster image (if present)
                        // and disable the thumbnail button to prevent further clicks
                        uiPlayButton.Visibility     = Visibility.Collapsed;
                        uiThumbnailButton.IsEnabled = false;
                    }
                    else
                    {
                        // Otherwise, collapse all the thumbnail button
                        uiThumbnailButton.Visibility = Visibility.Collapsed;
                    }

                    // Show the media player to start
                    uiMediaPlayer.Visibility = Visibility.Visible;
                }
                // Raise an event to send the media to host
                else
                {
                    context.ClickMedia(uiPosterContainer, new AdaptiveMediaEventArgs(media));

                    // Prevent nested events from triggering
                    e.Handled = true;
                }
            };

            return(uiMedia);
        }