private async void LoadData()
        {
            try
            {
                DataStories = JsonConvert.DeserializeObject <FetchStoriesObject.Data>(Intent.GetStringExtra("DataItem"));
                if (DataStories != null)
                {
                    GlideImageLoader.LoadImage(this, DataStories.Avatar, UserImageView, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);
                    UsernameTextView.Text = DataStories.Name;

                    DeleteIconView.Visibility = DataStories.Owner ? ViewStates.Visible : ViewStates.Invisible;

                    int count = DataStories.Stories.Count;
                    StoriesProgress.Visibility = ViewStates.Visible;
                    StoriesProgress.SetStoriesCount(count);   // <- set stories
                    StoriesProgress.SetStoriesListener(this); // <- set listener
                    //StoriesProgress.SetStoryDuration(10000L); // <- set a story duration

                    FetchStoriesObject.Story fistStory = DataStories.Stories.FirstOrDefault();
                    if (fistStory != null)
                    {
                        StoriesProgress.SetStoriesCountWithDurations(DataStories.DurationsList.ToArray());

                        await SetStory(fistStory);

                        StoriesProgress.StartStories(); // <- start progress
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 2
0
        private async void LoadData(GetUserStoriesObject.StoryObject dataStories)
        {
            try
            {
                if (dataStories == null)
                {
                    return;
                }

                GlideImageLoader.LoadImage(this, dataStories.Avatar, UserImageView, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);
                UsernameTextView.Text     = WoWonderTools.GetNameFinal(dataStories);
                DeleteIconView.Visibility = dataStories.Stories[0].IsOwner ? ViewStates.Visible : ViewStates.Invisible;

                StoriesProgress ??= FindViewById <StoriesProgressView>(Resource.Id.stories);
                if (StoriesProgress != null)
                {
                    StoriesProgress.Visibility = ViewStates.Visible;

                    int count = dataStories.Stories.Count;
                    StoriesProgress.Visibility = ViewStates.Visible;
                    StoriesProgress.SetStoriesCount(count);   // <- set stories
                    StoriesProgress.SetStoriesListener(this); // <- set listener
                    //StoriesProgress.SetStoryDuration(10000L); // <- set a story duration

                    var fistStory = dataStories.Stories.FirstOrDefault();
                    if (fistStory != null)
                    {
                        StoriesProgress.SetStoriesCountWithDurations(dataStories.DurationsList.ToArray());

                        await SetStory(fistStory);

                        StoriesProgress.StartStories(); // <- start progress
                    }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
        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);
            }
        }