public IMediaSource CreateCacheMediaSource(IMediaSource videoSource, Android.Net.Uri videoUrL)
        {
            try
            {
                if (Player_Settings.EnableOfflineMode)
                {
                    //Set the video for offline mode
                    if (!string.IsNullOrEmpty(Videodata.id))
                    {
                        string file = VideoDownloadAsyncControler.GetDownloadedDiskVideoUri(Videodata.id);

                        SimpleCache            cache           = new SimpleCache(ActivityContext.CacheDir, new LeastRecentlyUsedCacheEvictor(1024 * 1024 * 10));
                        CacheDataSourceFactory cacheDataSource = new CacheDataSourceFactory(cache, DefaultDatamediaFactory);

                        if (file != null)
                        {
                            videoUrL    = Android.Net.Uri.Parse(file);
                            videoSource = new ExtractorMediaSource(videoUrL, cacheDataSource, new DefaultExtractorsFactory(), mainHandler, eventLogger);
                            return(videoSource);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception exception)
            {
                Crashes.TrackError(exception);
                return(null);
            }
        }
        //Download
        private void Download_icon_Click(object sender, EventArgs e)
        {
            try
            {
                if (Download_icon.Tag.ToString() == "false")
                {
                    Download_icon.SetImageDrawable(ActivityContext.GetDrawable(Resource.Drawable.ic_action_download_stop));
                    Download_icon.Tag = "true";

                    string urlVideo = string.Empty;
                    if (Videodata.source.Contains("youtube") || Videodata.source.Contains("Youtube") || Videodata.source.Contains("youtu"))
                    {
                        urlVideo = VideoInfoRetriever.VideoDownloadstring;
                        if (!string.IsNullOrEmpty(urlVideo))
                        {
                            VideoControler = new VideoDownloadAsyncControler(urlVideo, Videodata.source, ActivityContext);
                            if (!VideoControler.CheckDownloadLinkIfExits())
                            {
                                VideoControler.StartDownloadManager(Videodata.name, Videodata);
                            }
                        }
                        else
                        {
                            IMethods.DialogPopup.InvokeAndShowDialog(ActivityContext, ActivityContext.GetString(Resource.String.Lbl_Error), ActivityContext.GetString(Resource.String.Lbl_You_can_not_Download_video), ActivityContext.GetString(Resource.String.Lbl_Ok));
                        }
                    }
                    else
                    {
                        urlVideo = Videodata.source;

                        VideoControler = new VideoDownloadAsyncControler(urlVideo, Videodata.id, ActivityContext);
                        if (!VideoControler.CheckDownloadLinkIfExits())
                        {
                            VideoControler.StartDownloadManager(Videodata.name, Videodata);
                        }
                    }
                }
                else if (Download_icon.Tag.ToString() == "Downloaded")
                {
                    try
                    {
                        AlertDialog.Builder builder = new AlertDialog.Builder(ActivityContext);
                        builder.SetTitle(ActivityContext.GetString(Resource.String.Lbl_Delete_video));
                        builder.SetMessage(ActivityContext.GetString(Resource.String.Lbl_Do_You_want_to_remove_video));

                        builder.SetPositiveButton(ActivityContext.GetString(Resource.String.Lbl_Yes), delegate(object o, DialogClickEventArgs args)
                        {
                            try
                            {
                                VideoDownloadAsyncControler.RemoveDiskVideoFile(Videodata.id + ".mp4");
                                Download_icon.SetImageDrawable(ActivityContext.GetDrawable(Resource.Drawable.ic_action_download));
                                Download_icon.Tag = "false";
                            }
                            catch (Exception exception)
                            {
                                Crashes.TrackError(exception);
                            }
                        });

                        builder.SetNegativeButton(ActivityContext.GetString(Resource.String.Lbl_No), delegate(object o, DialogClickEventArgs args)
                        {
                        });

                        var alert = builder.Create();
                        alert.Show();
                    }
                    catch (System.Exception exception)
                    {
                        Crashes.TrackError(exception);
                    }
                }
                else
                {
                    Download_icon.SetImageDrawable(ActivityContext.GetDrawable(Resource.Drawable.ic_action_download));
                    Download_icon.Tag = "false";
                    VideoControler.StopDownloadManager();
                }
            }
            catch (System.Exception exception)
            {
                Crashes.TrackError(exception);
            }
        }