public VideoPage(string source) { Source = source; InitializeComponent(); SetUseNativePlayer(); if (UseWebPlayer) { VideoPlayerView.IsEnabled = false; VideoPlayerView.IsVisible = false; VideoWebView = new FormsWebView(); VideoWebView.Source = "video.html"; VideoWebView.ContentType = Xam.Plugin.WebView.Abstractions.Enumerations.WebViewContentType.LocalFile; VideoStack.Children.Add(VideoWebView); VideoWebView.OnContentLoaded += VideoWebView_OnContentLoaded; VideoWebView.AddLocalCallback("RaiseEndedEvent", LoadNextVideo); } ViewModel = new VideoPageViewModel(); this.BindingContext = ViewModel; }
public static void CopyVideoUrl(VideoPageViewModel viewModel) { if (viewModel == null) { return; } Clipboard.SetText(string.Format("https://www.youtube.com/watch?v={0}", viewModel.VideoId)); }
public static void AddToPlaylist(VideoPageViewModel viewModel) { if (viewModel == null) { return; } viewModel.ShowContainer(!viewModel.PlaylistListViewModel.IsContainerShown, viewModel.VideoId); }
public static void SendComment(VideoPageViewModel viewModel) { if (viewModel == null) { return; } viewModel.CommentsViewModel.AddCommentCommand.Execute(null); }
public static void AddToFavorites(VideoPageViewModel viewModel) { if (viewModel == null) { return; } viewModel.AddFavoritesCommand.Execute(null); }
private void BuildViewModel(Sitecore.Data.Items.Item contextItem) { _vpvm = new VideoPageViewModel(); _vpvm.VideoUrl = Utilities.SitecoreHelper.FieldMethods.GetFileUrl(contextItem, "Video File"); _vpvm.ThumbnailImageUrl = Utilities.SitecoreHelper.FieldMethods.GetMediaItemUrlWithHash(contextItem, "Thumbnail Image"); _vpvm.BreadcrumbItems = BreadcrumbItems; }
public void SetLayout(bool isLandscape) { bindingContext = BindingContext as VideoPageViewModel; if (!bindingContext.CombinatingIsVisible) { bindingContext.IsFullScreen = isLandscape; bindingContext.IsMenuVisible = !isLandscape; bindingContext.MenuHeight = isLandscape ? 0 : 40; if (isLandscape) { if (savedHeader == null) { savedHeader = commentsListView.Header; } commentsListView.Footer = hiddenFooter; commentsListView.ItemsSource = null; commentsListView.IsPullToRefreshEnabled = false; Padding = 0; SetLayoutHeights(Height); AbsoluteLayout.SetLayoutBounds(Header, new Rectangle(0, 230, 1, 0)); } else { if (savedHeader != null) { commentsListView.Header = savedHeader; } if (null != bindingContext.commentsItemsSource && bindingContext.commentsItemsSource.Count > 0) { commentsListView.ItemsSource = bindingContext.commentsItemsSource; } commentsListView.IsPullToRefreshEnabled = true; var padding = 0; switch (Device.RuntimePlatform) { case "iOS": padding = 20; break; default: break; } Padding = new Thickness(0, padding, 0, 0); var videoPlayerHeight = width / 16 * 9; SetLayoutHeights(videoPlayerHeight); AbsoluteLayout.SetLayoutBounds(Header, new Rectangle(0, videoPlayerHeight, 1, -1)); } } }
private void Initialize() { this.Loaded += VideoPage_Loaded; viewModel = new VideoPageViewModel(); viewModel.Initialize(inkCanvas); viewModel.TogglePlayPauseEvent += TogglePlayPause; Scrubber.ValueChanged += Scrubber_ValueChanged; this.DataContext = viewModel; }
public async Task <VideoPageViewModel> GetVideoPage(int pageSize, int id, int progenyId, int userAccessLevel, int sortBy, string tagFilter, string timeZone) { var currentContext = _httpContextAccessor.HttpContext; string accessToken = await currentContext.GetTokenAsync(OpenIdConnectParameterNames.AccessToken).ConfigureAwait(false); //HttpClient _httpClient = new HttpClient(); if (!string.IsNullOrWhiteSpace(accessToken)) { _httpClient.SetBearerToken(accessToken); } else { accessToken = await GetNewToken(); _httpClient.SetBearerToken(accessToken); } string pageApiPath = "/api/videos/page?pageSize=" + pageSize + "&pageIndex=" + id + "&progenyId=" + progenyId + "&accessLevel=" + userAccessLevel + "&sortBy=" + sortBy; if (tagFilter != "") { pageApiPath = pageApiPath + "&tagFilter=" + tagFilter; } pageApiPath = pageApiPath + "&timeZone=" + timeZone; var pageResponseString = await _httpClient.GetStringAsync(pageApiPath); VideoPageViewModel model = JsonConvert.DeserializeObject <VideoPageViewModel>(pageResponseString); if (timeZone != "") { foreach (Video vid in model.VideosList) { if (vid.VideoTime.HasValue) { vid.VideoTime = TimeZoneInfo.ConvertTimeFromUtc(vid.VideoTime.Value, TimeZoneInfo.FindSystemTimeZoneById(timeZone)); } } } return(model); }
protected override async Task OnInitializedAsync() { videoPageViewModel = await videoService.GetById(Id); }
public async Task <IActionResult> PageMobile([FromQuery] int pageSize = 8, [FromQuery] int pageIndex = 1, [FromQuery] int progenyId = 2, [FromQuery] int accessLevel = 5, [FromQuery] string tagFilter = "", [FromQuery] int sortBy = 1) { // Check if user should be allowed access. string userEmail = User.GetEmail() ?? Constants.DefaultUserEmail; UserAccess userAccess = await _dataService.GetProgenyUserAccessForUser(progenyId, userEmail); if (userAccess == null && progenyId != Constants.DefaultChildId) { return(Unauthorized()); } if (pageIndex < 1) { pageIndex = 1; } List <Video> allItems; allItems = await _dataService.GetVideosList(progenyId); List <string> tagsList = new List <string>(); foreach (Video vid in allItems) { if (!String.IsNullOrEmpty(vid.Tags)) { List <string> pvmTags = vid.Tags.Split(',').ToList(); foreach (string tagstring in pvmTags) { if (!tagsList.Contains(tagstring.TrimStart(' ', ',').TrimEnd(' ', ','))) { tagsList.Add(tagstring.TrimStart(' ', ',').TrimEnd(' ', ',')); } } } } if (!string.IsNullOrEmpty(tagFilter)) { allItems = allItems.Where(p => p.AccessLevel >= accessLevel && p.Tags != null && p.Tags.ToUpper().Contains(tagFilter.ToUpper())).OrderBy(p => p.VideoTime).ToList(); } else { allItems = allItems.Where(p => p.AccessLevel >= accessLevel).OrderBy(p => p.VideoTime).ToList(); } if (sortBy == 1) { allItems.Reverse(); } int videoCounter = 1; int vidCount = allItems.Count; foreach (Video vid in allItems) { if (sortBy == 1) { vid.VideoNumber = vidCount - videoCounter + 1; } else { vid.VideoNumber = videoCounter; } videoCounter++; if (vid.Duration != null) { vid.DurationHours = vid.Duration.Value.Hours.ToString(); vid.DurationMinutes = vid.Duration.Value.Minutes.ToString(); vid.DurationSeconds = vid.Duration.Value.Seconds.ToString(); if (vid.DurationSeconds.Length == 1) { vid.DurationSeconds = "0" + vid.DurationSeconds; } if (vid.Duration.Value.Hours != 0) { if (vid.DurationMinutes.Length == 1) { vid.DurationMinutes = "0" + vid.DurationMinutes; } } } } var itemsOnPage = allItems.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList(); foreach (Video vid in itemsOnPage) { vid.Comments = await _dataService.GetCommentsList(vid.CommentThreadNumber); } VideoPageViewModel model = new VideoPageViewModel(); model.VideosList = itemsOnPage; model.TotalPages = (int)Math.Ceiling(allItems.Count / (double)pageSize); model.PageNumber = pageIndex; model.SortBy = sortBy; model.TagFilter = tagFilter; string tList = ""; foreach (string tstr in tagsList) { tList = tList + tstr + ","; } model.TagsList = tList.TrimEnd(','); return(Ok(model)); }
public async Task <IActionResult> Index(int id = 1, int pageSize = 8, int childId = 0, int sortBy = 1, string tagFilter = "") { _progId = childId; if (id < 1) { id = 1; } string userEmail = HttpContext.User.FindFirst("email")?.Value ?? _defaultUser; string userTimeZone = HttpContext.User.FindFirst("timezone")?.Value ?? Constants.DefaultTimezone; if (string.IsNullOrEmpty(userTimeZone)) { userTimeZone = Constants.DefaultTimezone; } UserInfo userinfo = await _progenyHttpClient.GetUserInfo(userEmail); if (childId == 0 && userinfo.ViewChild > 0) { _progId = userinfo.ViewChild; } else { _progId = childId; } if (_progId == 0) { _progId = Constants.DefaultChildId; } Progeny progeny = await _progenyHttpClient.GetProgeny(_progId); if (progeny == null) { progeny = new Progeny(); progeny.Admins = Constants.AdminEmail; progeny.Id = 0; progeny.BirthDay = DateTime.UtcNow; progeny.Name = "No Children in the Database"; progeny.NickName = "No default child defined"; progeny.TimeZone = Constants.DefaultTimezone; progeny.PictureLink = Constants.ProfilePictureUrl; } List <UserAccess> accessList = await _progenyHttpClient.GetProgenyAccessList(_progId); int userAccessLevel = (int)AccessLevel.Public; if (accessList.Count != 0) { UserAccess userAccess = accessList.SingleOrDefault(u => u.UserId.ToUpper() == userEmail.ToUpper()); if (userAccess != null) { userAccessLevel = userAccess.AccessLevel; } } if (progeny.IsInAdminList(userEmail)) { _userIsProgenyAdmin = true; userAccessLevel = (int)AccessLevel.Private; } VideoPageViewModel model = await _mediaHttpClient.GetVideoPage(pageSize, id, progeny.Id, userAccessLevel, sortBy, tagFilter, userTimeZone); model.Progeny = progeny; model.IsAdmin = _userIsProgenyAdmin; model.SortBy = sortBy; return(View(model)); }
public VideoPage() { InitializeComponent(); _viewModel = (VideoPageViewModel)BindingContext; }