private async void AddVideoExecute() { if (NewVideo != null) { var video = new FiveMinVideo { Name = NewVideo.Name, Categories = new List<string> { SelectedCategory.Name }, Description = NewVideo.Description, ImageUrl = NewVideo.BackdropUrl, DateAdded = DateTime.Now, Likes = 0, Dislikes = 0, WatchCount = 0, IsWatched = false, VideoId = NewVideo.VideoUrl, Keywords = NewVideo.KeywordsFormatted, Length = NewVideo.LengthFormatted }; await FirebaseManager.Instance.AddVideo(video); Videos.Add(video); NewVideo = new VideoViewModel(); } }
/// <summary> /// Given a video object, starts an activity with the video ready to be played /// </summary> /// <param name="video">The video to play.</param> /// <param name="view">The view from which this is called.</param> public static void StartVideo(FiveMinVideo video, View view) { FirebaseManager.Instance.UpdateWatchCount (video); // Put the name of the selected category into the intent var intent = new Intent (view.Context, typeof (VideoActivity)); intent.PutExtra ("VideoId", video.VideoId); intent.PutExtra ("VideoKey", video.Key); intent.PutExtra ("VideoName", video.Name); intent.PutExtra ("VideoDescription", video.Description); intent.PutExtra ("WatchCount", video.WatchCount.ToString ("N0")); intent.PutExtra ("LikesDiff", (video.Likes - video.Dislikes).ToString ("N0")); intent.PutExtra ("Length", StringHelper.TimeSpanFormatter (video.Length)); view.Context.StartActivity (intent); }
public void UpdateLikesDislikesCount (FiveMinVideo v, bool isIncrement, bool isLikes) { if (isLikes) { if (isIncrement) { v.Likes++; } else { v.Likes--; } } else { if (isIncrement) { v.Dislikes++; } else { v.Dislikes--; } } UpdateVideo (v); }
private async void UpdateVideo (FiveMinVideo value) { var key = GetKeyForVideo (value); await _client.UpdateAsync ($"{VideosName}/{key}", value); }
public async Task<bool> AddVideo (FiveMinVideo video) { var response = await _client.PushAsync (VideosName, video); return response.StatusCode == HttpStatusCode.OK; }
public string GetKeyForVideo (FiveMinVideo v) { return _videos.FirstOrDefault (vid => vid.Value == v).Key; }
public void UpdateWatchCount (FiveMinVideo v) { if (v != null) { v.WatchCount++; UpdateVideo (v); } }