Esempio n. 1
0
        private void SetImage(VideoModel video)
        {
            if (!string.IsNullOrEmpty(video.Image))
            {
                // HTTPS address
                video.ImageSecure = video.Image;

                // HTTP address
                var builder = new UriBuilder(video.Image) { Scheme = "http", Port = 80 };
                video.Image = builder.Uri.ToString();
            }
        }
Esempio n. 2
0
        private VideoModel CreateVideoModel(string id)
        {
            string queryString = Request.QueryString.ToString();
            if (queryString.Length > 0)
            {
                queryString = string.Format(@"?{0}", queryString);
            }

            // HTTP addresses
            var video = new VideoModel
            {
                VideoUrl = _projectUriProvider.GetUri(id) + queryString,
                EmbedUrl = Url.RouteUrl(RouteNames.Embed, new { id, autoplay = 1 }, "http")
            };

            // HTTPS address
            var builder = new UriBuilder(video.VideoUrl) { Scheme = "https", Port = 443 };
            video.VideoSecureUrl = builder.Uri.ToString();

            builder = new UriBuilder(video.EmbedUrl) { Scheme = "https", Port = 443 };
            video.EmbedSecureUrl = builder.Uri.ToString();

            video.Robot = GetProvider(Request.UserAgent);

            return video;
        }
Esempio n. 3
0
        private void OverrideParams(VideoModel video)
        {
            // Override title from query string
            if (!string.IsNullOrEmpty(Request.Params[TitleParam]))
            {
                video.Name = Request.Params[TitleParam];
            }

            // Override description from query string
            if (!string.IsNullOrEmpty(Request.Params[DescriptionParam]))
            {
                video.Description = Request.Params[DescriptionParam];
            }

            // Override image from query string
            if (!string.IsNullOrEmpty(Request.Params[ImageParam]))
            {
                Uri uri;

                if (Uri.TryCreate(Request.Params[ImageParam], UriKind.Absolute, out uri))
                {
                    video.Image = uri.AbsoluteUri;
                }
            }
        }