//delete story private async void DeleteIconViewOnClick(object sender, EventArgs e) { try { StoriesProgress.Pause(); if (StoryVideoView.IsPlaying) { StoryVideoView.Pause(); } if (Methods.CheckConnectivity()) { (int respondCode, var respond) = await RequestsAsync.Story.Delete_Story(StoryId).ConfigureAwait(false); if (respondCode == 200) { RunOnUiThread(() => { var modelStory = GlobalContext.NewsFeedTab.PostFeedAdapter.HolderStory.StoryAdapter; var story = modelStory?.StoryList?.FirstOrDefault(a => a.UserId == UserId); if (story == null) { return; } var item = story.Stories.FirstOrDefault(q => q.Id == StoryId); if (item != null) { story.Stories.Remove(item); modelStory.NotifyItemChanged(modelStory.StoryList.IndexOf(story)); if (story.Stories.Count == 0) { modelStory?.StoryList.Remove(story); modelStory.NotifyDataSetChanged(); } } Finish(); }); Toast.MakeText(this, GetString(Resource.String.Lbl_Deleted), ToastLength.Short).Show(); } else { Methods.DisplayReportResult(this, respond); } } else { Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } } catch (Exception exception) { Console.WriteLine(exception); } }
private void PlayIconVideoOnClick(object sender, EventArgs e) { try { if (PlayIconVideo.Tag.ToString() == "Play") { MediaMetadataRetriever retriever; if (PathStory.Contains("http")) { StoryVideoView.SetVideoURI(Uri.Parse(PathStory)); retriever = new MediaMetadataRetriever(); if ((int)Build.VERSION.SdkInt >= 14) { retriever.SetDataSource(PathStory, new Dictionary <string, string>()); } else { retriever.SetDataSource(PathStory); } } else { var file = Uri.FromFile(new File(PathStory)); StoryVideoView.SetVideoPath(file.Path); retriever = new MediaMetadataRetriever(); //if ((int)Build.VERSION.SdkInt >= 14) // retriever.SetDataSource(file.Path, new Dictionary<string, string>()); //else // retriever.SetDataSource(file.Path); retriever.SetDataSource(file.Path); } StoryVideoView.Start(); Duration = Long.ParseLong(retriever.ExtractMetadata(MetadataKey.Duration)); retriever.Release(); StoriesProgress.Visibility = ViewStates.Visible; StoriesProgress.SetStoriesCount(1); // <- set stories StoriesProgress.SetStoryDuration(Duration); // <- set a story duration StoriesProgress.StartStories(); // <- start progress PlayIconVideo.Tag = "Stop"; PlayIconVideo.SetImageResource(Resource.Drawable.ic_stop_white_24dp); } else { StoriesProgress.Visibility = ViewStates.Gone; StoriesProgress.Pause(); StoryVideoView.Pause(); PlayIconVideo.Tag = "Play"; PlayIconVideo.SetImageResource(Resource.Drawable.ic_play_arrow); } } catch (Exception ex) { Console.WriteLine(ex); } }
private void PlayIconVideoOnClick(object sender, EventArgs e) { try { switch (PlayIconVideo?.Tag?.ToString()) { case "Play": { MediaMetadataRetriever retriever; if (PathStory.Contains("http")) { StoryVideoView.SetVideoURI(Uri.Parse(PathStory)); retriever = new MediaMetadataRetriever(); switch ((int)Build.VERSION.SdkInt) { case >= 14: retriever.SetDataSource(PathStory, new Dictionary <string, string>()); break; default: retriever.SetDataSource(PathStory); break; } } else { var file = Uri.FromFile(new File(PathStory)); StoryVideoView.SetVideoPath(file?.Path); retriever = new MediaMetadataRetriever(); //if ((int)Build.VERSION.SdkInt >= 14) // retriever.SetDataSource(file.Path, new Dictionary<string, string>()); //else // retriever.SetDataSource(file.Path); retriever.SetDataSource(file?.Path); } StoryVideoView.Start(); Duration = Long.ParseLong(retriever.ExtractMetadata(MetadataKey.Duration) ?? string.Empty); retriever.Release(); StoriesProgress.Visibility = ViewStates.Visible; StoriesProgress.SetStoriesCount(1); // <- set stories StoriesProgress.SetStoryDuration(Duration); // <- set a story duration StoriesProgress.StartStories(); // <- start progress PlayIconVideo.Tag = "Stop"; PlayIconVideo.SetImageResource(Resource.Drawable.ic_stop_white_24dp); break; } default: { StoriesProgress.Visibility = ViewStates.Gone; StoriesProgress.Pause(); StoryVideoView.Pause(); if (PlayIconVideo != null) { PlayIconVideo.Tag = "Play"; PlayIconVideo.SetImageResource(Resource.Drawable.ic_play_arrow); } break; } } } catch (Exception ex) { Methods.DisplayReportResultTrack(ex); } }