コード例 #1
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            try
            {
                string videoUrl = await VimeoHelpers.GetVideoUrl(e.Parameter.ToString());

                videoPlayer.Source = new Uri(videoUrl);

                base.OnNavigatedTo(e);
            }

            catch (Exception)
            {
            }
        }
コード例 #2
0
        private async Task CalcDuration(TR translation)
        {
            if (translation is IWithUrlAndDuration {
                Url : { }
            } withVimeo)
            {
                var vimeoVideo = await VimeoHelpers.GetVideoAsync(withVimeo.Url);

                if (vimeoVideo == null)
                {
                    withVimeo.Duration = null;
                    ModelState.AddModelError("", "Url некорректна или видео не найдено ");
                }
                else
                {
                    withVimeo.Duration = vimeoVideo.Video?.DurationFmt;
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Gets the URL for a thumbnail with the specified size.
        /// </summary>
        /// <param name="vimeoId">The ID of the video.</param>
        /// <param name="size">The size of the desired thumbnail.</param>
        public static string GetVimeoThumbnail(this string vimeoId, VimeoThumbnail size)
        {
            VimeoVideo video = VimeoHelpers.GetCachedVideoById(vimeoId);

            if (video == null)
            {
                return(null);
            }
            switch (size)
            {
            case VimeoThumbnail.Small:
                return(video.ThumbnailSmall);

            case VimeoThumbnail.Medium:
                return(video.ThumbnailMedium);

            default:
                return(video.ThumbnailLarge);
            }
        }
コード例 #4
0
 /// <summary>
 /// Generates the HTML iframe for embedding a Vimeo video based on the specified ID.
 /// </summary>
 /// <param name="vimeoId">The ID of the video.</param>
 /// <param name="width">The width of the iframe.</param>
 /// <param name="height">The height of the iframe.</param>
 public static string VimeoEmbed(this int vimeoId, int width, int height)
 {
     return(VimeoHelpers.GetEmbedHtml(vimeoId, width, height));
 }
コード例 #5
0
        /// <summary>
        /// Gets the duration of the Vimeo video with the specified ID.
        /// </summary>
        /// <param name="vimeoId">The ID of the video.</param>
        /// <returns>Returns the duration in seconds if the video is found, otherwise <var>-1</var> will be returned.</returns>
        public static int GetVimeoDuration(this string vimeoId)
        {
            VimeoVideo video = VimeoHelpers.GetCachedVideoById(vimeoId);

            return(video == null ? -1 : (int)video.Duration.TotalSeconds);
        }