Ejemplo n.º 1
0
        public void ReleaseVideo()
        {
            try
            {
                if (Player != null)
                {
                    Player?.Release();
                    Player = null;

                    //GC Collecter
                    GC.Collect();
                }

                if (Download_icon.Tag.ToString() != "false")
                {
                    Download_icon.SetImageDrawable(ActivityContext.GetDrawable(Resource.Drawable.ic_action_download));
                    Download_icon.Tag = "false";
                }

                videoDescriptionLayout.Visibility = ViewStates.Visible;

                if (Videodata != null)
                {
                    Video_Titile.Text = Videodata.name;
                }

                simpleExoPlayerView.Player = null;
            }
            catch (Exception exception)
            {
                Crashes.TrackError(exception);
            }
        }
Ejemplo n.º 2
0
 public void RestartPlayAfterShrinkScreen()
 {
     try
     {
         SimpleExoPlayerView.Player = null !;
         SimpleExoPlayerView.Player = Player;
         SimpleExoPlayerView.Player.PlayWhenReady = true;
         MFullScreenIcon.SetImageDrawable(ActivityContext.GetDrawable(Resource.Drawable.ic_action_ic_fullscreen_expand));
     }
     catch (Exception exception)
     {
         Methods.DisplayReportResultTrack(exception);
     }
 }
Ejemplo n.º 3
0
 public void RestartPlayAfterShrinkScreen()
 {
     try
     {
         SimpleExoPlayerView.Player = null;
         SimpleExoPlayerView.Player = Player;
         SimpleExoPlayerView.Player.PlayWhenReady = true;
         MFullScreenIcon.SetImageDrawable(ActivityContext.GetDrawable(Resource.Drawable.ic_action_ic_fullscreen_expand));
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
Ejemplo n.º 4
0
 public void RestartPlayAfterShrinkScreen()
 {
     try
     {
         simpleExoPlayerView.Player = null;
         simpleExoPlayerView.Player = Player;
         simpleExoPlayerView.Player.PlayWhenReady = true;
         mFullScreenIcon.SetImageDrawable(
             ActivityContext.GetDrawable(Resource.Drawable.ic_action_ic_fullscreen_expand));
     }
     catch (Exception exception)
     {
         Crashes.TrackError(exception);
     }
 }
Ejemplo n.º 5
0
 public void PlayFullScreen()
 {
     try
     {
         if (FullscreenplayerView != null)
         {
             Player?.AddListener(PlayerLitsener);
             FullscreenplayerView.Player = Player;
             FullscreenplayerView.Player.PlayWhenReady = true;
             mFullScreenIcon.SetImageDrawable(ActivityContext.GetDrawable(Resource.Drawable.ic_action_ic_fullscreen_skrink));
         }
     }
     catch (Exception exception)
     {
         Crashes.TrackError(exception);
     }
 }
Ejemplo n.º 6
0
 public void RestartPlayAfterShrinkScreen()
 {
     try
     {
         SimpleExoPlayerView.Player = null;
         if (FullScreenPlayerView != null)
         {
             Player?.AddListener(PlayerListener);
             Player.AddVideoListener(this);
             SimpleExoPlayerView.Player = FullScreenPlayerView.Player;
             SimpleExoPlayerView.Player.PlayWhenReady = true;
             SimpleExoPlayerView.RequestFocus();
             MFullScreenIcon.SetImageDrawable(ActivityContext.GetDrawable(Resource.Drawable.ic_action_ic_fullscreen_expand));
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
Ejemplo n.º 7
0
 public void PlayFullScreen()
 {
     try
     {
         if (FullscreenPlayerView != null)
         {
             Player?.AddListener(PlayerListener);
             FullscreenPlayerView.Player = Player;
             if (FullscreenPlayerView.Player != null)
             {
                 FullscreenPlayerView.Player.PlayWhenReady = true;
             }
             MFullScreenIcon.SetImageDrawable(ActivityContext.GetDrawable(Resource.Drawable.ic_action_ic_fullscreen_skrink));
         }
     }
     catch (Exception exception)
     {
         Methods.DisplayReportResultTrack(exception);
     }
 }
Ejemplo n.º 8
0
 public void PlayFullScreen(VideoObject videoObject)
 {
     try
     {
         VideoData = videoObject;
         if (FullScreenPlayerView != null)
         {
             Player.AddListener(PlayerListener);
             Player.AddVideoListener(this);
             FullScreenPlayerView.Player = Player;
             if (FullScreenPlayerView.Player != null)
             {
                 FullScreenPlayerView.Player.PlayWhenReady = true;
             }
             MFullScreenIcon.SetImageDrawable(ActivityContext.GetDrawable(Resource.Drawable.ic_action_ic_fullscreen_skrink));
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
Ejemplo n.º 9
0
        public void PlayVideo(string videoUrL, VideoObject videoObject, RestrictedVideoFragment restrictedVideoPlayerFragment, Activity activity)
        {
            try
            {
                //RestrictedVideoPlayerFragment = restrictedVideoPlayerFragment;
                //ActivityFragment = activity;

                if (videoObject != null)
                {
                    VideoData = videoObject;
                    ReleaseVideo();

                    bool vidMonit = ListUtils.MySettingsList?.UsrVMon == "on" && VideoData.Monetization == "1" && VideoData.Owner.VideoMon == "1";

                    if (ListUtils.ArrayListPlay.Count > 0)
                    {
                        ListUtils.ArrayListPlay.Remove(VideoData);
                    }

                    var isPro = ListUtils.MyChannelList.FirstOrDefault()?.IsPro ?? "0";
                    if (!AppSettings.AllowOfflineDownload || AppSettings.AllowDownloadProUser && isPro == "0")
                    {
                        DownloadIcon.Visibility = ViewStates.Gone;
                    }

                    MFullScreenIcon.SetImageDrawable(ActivityContext.GetDrawable(Resource.Drawable.ic_action_ic_fullscreen_expand));

                    LoadingProgressBar.Visibility = ViewStates.Visible;

                    Uri url;
                    //Rent Or Sell
                    if (!string.IsNullOrEmpty(VideoData.SellVideo) && VideoData.SellVideo != "0" || !string.IsNullOrEmpty(VideoData.RentPrice) && VideoData.RentPrice != "0" && AppSettings.RentVideosSystem)
                    {
                        if (!string.IsNullOrEmpty(VideoData.Demo) && VideoData.IsPurchased == "0")
                        {
                            if (!VideoData.Demo.Contains(Client.WebsiteUrl))
                            {
                                VideoData.Demo = Client.WebsiteUrl + "/" + VideoData.Demo;
                            }

                            url = Uri.Parse(VideoData.Demo);
                            ShowRestrictedVideo = true;
                        }
                        else if (VideoData.IsPurchased != "0")
                        {
                            url = Uri.Parse(!string.IsNullOrEmpty(videoUrL) ? videoUrL : VideoData.VideoLocation);
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(VideoData.SellVideo) && VideoData.SellVideo != "0")
                            {
                                ShowRestrictedVideoFragment(restrictedVideoPlayerFragment, activity, "purchaseVideo");
                            }
                            else if (!string.IsNullOrEmpty(VideoData.RentPrice) && VideoData.RentPrice != "0" && AppSettings.RentVideosSystem)
                            {
                                ShowRestrictedVideoFragment(restrictedVideoPlayerFragment, activity, "RentVideo");
                            }
                            return;
                        }
                    }
                    else
                    {
                        url = Uri.Parse(!string.IsNullOrEmpty(videoUrL) ? videoUrL : VideoData.VideoLocation);
                    }

                    AdaptiveTrackSelection.Factory trackSelectionFactory = new AdaptiveTrackSelection.Factory();
                    var trackSelector = new DefaultTrackSelector(trackSelectionFactory);

                    var newParameters = new DefaultTrackSelector.ParametersBuilder()
                                        .SetMaxVideoSizeSd()
                                        .SetPreferredAudioLanguage("deu")
                                        .Build();

                    trackSelector.SetParameters(newParameters);

                    Player = ExoPlayerFactory.NewSimpleInstance(ActivityContext, trackSelector);

                    FullWidthSetting();

                    DefaultDataMediaFactory = new DefaultDataSourceFactory(ActivityContext, Util.GetUserAgent(ActivityContext, AppSettings.ApplicationName), BandwidthMeter);

                    VideoSource = null;

                    // Produces DataSource instances through which media data is loaded.
                    VideoSource = GetMediaSourceFromUrl(url, "normal");

                    if (SimpleExoPlayerView == null)
                    {
                        Initialize();
                    }

                    //Set Cache Media Load
                    if (PlayerSettings.EnableOfflineMode)
                    {
                        VideoSource = CreateCacheMediaSource(VideoSource, url);

                        if (VideoSource != null)
                        {
                            DownloadIcon.SetImageResource(Resource.Drawable.ic_checked_red);
                            DownloadIcon.Tag = "Downloaded";

                            RunVideoWithAds(VideoSource, vidMonit);
                            return;
                        }
                    }

                    //Set Interactive Media Ads
                    if (isPro == "0" && PlayerSettings.ShowInteractiveMediaAds && vidMonit)
                    {
                        VideoSource = CreateMediaSourceWithAds(VideoSource, PlayerSettings.ImAdsUri);
                    }

                    if (VideoSource == null)
                    {
                        VideoSource = GetMediaSourceFromUrl(url, "normal");

                        RunVideoWithAds(VideoSource, vidMonit);
                    }
                    else
                    {
                        RunVideoWithAds(VideoSource, vidMonit);
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Ejemplo n.º 10
0
        public void PlayVideo(string videoUrL, GetMoviesObject.Movie videoObject)
        {
            try
            {
                if (videoObject != null)
                {
                    VideoData = videoObject;

                    VideoViewerActivity.GetInstance()?.TabVideosAbout?.LoadVideo_Data(videoObject);

                    TabbedMainActivity.GetInstance()?.SetOnWakeLock();

                    ReleaseVideo();

                    MFullScreenIcon.SetImageDrawable(ActivityContext.GetDrawable(Resource.Drawable.ic_action_ic_fullscreen_expand));

                    Uri videoUrl = Uri.Parse(!string.IsNullOrEmpty(videoUrL) ? videoUrL : VideoData.Source);

                    AdaptiveTrackSelection.Factory trackSelectionFactory = new AdaptiveTrackSelection.Factory();
                    var trackSelector = new DefaultTrackSelector(DefaultTrackSelector.Parameters.GetDefaults(ActivityContext), trackSelectionFactory);
                    trackSelector.SetParameters(new DefaultTrackSelector.ParametersBuilder(ActivityContext));

                    Player = new SimpleExoPlayer.Builder(ActivityContext).Build();

                    // Produces DataSource instances through which media data is loaded.
                    var defaultSource = GetMediaSourceFromUrl(videoUrl, videoUrl?.Path?.Split('.').Last(), "normal", IDrmSessionManager.DummyDrmSessionManager);

                    VideoSource = null !;

                    //Set Interactive Media Ads
                    if (PlayerSettings.ShowInteractiveMediaAds)
                    {
                        VideoSource = CreateMediaSourceWithAds(defaultSource, PlayerSettings.ImAdsUri);
                    }

                    if (SimpleExoPlayerView == null)
                    {
                        Initialize();
                    }

                    //Set Cache Media Load
                    if (PlayerSettings.EnableOfflineMode)
                    {
                        VideoSource = VideoSource == null?CreateCacheMediaSource(defaultSource, videoUrl) : CreateCacheMediaSource(VideoSource, videoUrl);

                        if (VideoSource != null)
                        {
                            SimpleExoPlayerView.Player = Player;
                            Player.Prepare(VideoSource);
                            //Player.AddListener(PlayerListener);
                            Player.PlayWhenReady = true;

                            bool haveResumePosition = ResumeWindow != C.IndexUnset;
                            if (haveResumePosition)
                            {
                                Player.SeekTo(ResumeWindow, ResumePosition);
                            }

                            return;
                        }
                    }

                    if (VideoSource == null)
                    {
                        if (!string.IsNullOrEmpty(videoUrL))
                        {
                            if (videoUrL.Contains("youtube") || videoUrL.Contains("Youtube") || videoUrL.Contains("youtu"))
                            {
                                //Task.Factory.StartNew(async () =>
                                //{
                                //    var newurl = await VideoInfoRetriever.GetEmbededVideo(VideoData.source);
                                //    videoSource = CreateDefaultMediaSource(Android.Net.Uri.Parse(newurl));
                                //});
                            }
                            else
                            {
                                VideoSource = GetMediaSourceFromUrl(Uri.Parse(videoUrL), videoUrL?.Split('.').Last(), "normal", IDrmSessionManager.DummyDrmSessionManager);

                                SimpleExoPlayerView.Player = Player;
                                Player.Prepare(VideoSource);
                                //Player.AddListener(PlayerListener);
                                Player.PlayWhenReady = true;

                                bool haveResumePosition = ResumeWindow != C.IndexUnset;
                                if (haveResumePosition)
                                {
                                    Player.SeekTo(ResumeWindow, ResumePosition);
                                }
                            }
                        }
                    }
                    else
                    {
                        SimpleExoPlayerView.Player = Player;
                        Player.Prepare(VideoSource);
                        //Player.AddListener(PlayerListener);
                        Player.PlayWhenReady = true;

                        bool haveResumePosition = ResumeWindow != C.IndexUnset;
                        if (haveResumePosition)
                        {
                            Player.SeekTo(ResumeWindow, ResumePosition);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
Ejemplo n.º 11
0
        //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);
            }
        }
Ejemplo n.º 12
0
        public void PlayVideo(string videoUrL, Get_Movies_Object.Movie videoObject)
        {
            try
            {
                if (videoObject != null)
                {
                    Videodata = videoObject;

                    LoadVideo_Data(videoObject);

                    ReleaseVideo();

                    if (Settings.Allow_Offline_Download == false)
                    {
                        Download_icon.Visibility = ViewStates.Gone;
                    }

                    mFullScreenIcon.SetImageDrawable(ActivityContext.GetDrawable(Resource.Drawable.ic_action_ic_fullscreen_expand));

                    Android.Net.Uri videoURL;
                    if (!string.IsNullOrEmpty(videoUrL))
                    {
                        videoURL = Android.Net.Uri.Parse(videoUrL);
                    }
                    else
                    {
                        videoURL = Android.Net.Uri.Parse(Videodata.source);
                    }

                    mainHandler = new Handler();

                    AdaptiveTrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(BANDWIDTH_METER);
                    DefaultTrackSelector           trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);

                    Player = ExoPlayerFactory.NewSimpleInstance(ActivityContext, trackSelector);
                    DefaultDatamediaFactory = new DefaultDataSourceFactory(ActivityContext, Util.GetUserAgent(ActivityContext, Settings.Application_Name), BANDWIDTH_METER);

                    // Produces DataSource instances through which media data is loaded.
                    ExtractorMediaSource DefaultSource = new ExtractorMediaSource(videoURL, DefaultDatamediaFactory, new DefaultExtractorsFactory(), mainHandler, eventLogger);

                    videoSource = null;

                    //Set Interactive Media Ads
                    if (Player_Settings.ShowInteractiveMediaAds)
                    {
                        videoSource = CreateAdsMediaSource(DefaultSource, Player_Settings.IMAdsUri);
                    }

                    if (simpleExoPlayerView == null)
                    {
                        Initialize();
                    }

                    //Set Cache Media Load
                    if (Player_Settings.EnableOfflineMode)
                    {
                        videoSource = videoSource == null?CreateCacheMediaSource(DefaultSource, videoURL) : CreateCacheMediaSource(videoSource, videoURL);

                        if (videoSource != null)
                        {
                            Download_icon.SetImageDrawable(ActivityContext.GetDrawable(Resource.Drawable.ic_checked_red));
                            Download_icon.Tag = "Downloaded";

                            simpleExoPlayerView.Player = Player;
                            Player.Prepare(videoSource);
                            Player.AddListener(PlayerLitsener);
                            Player.PlayWhenReady = true;

                            bool haveResumePosition = resumeWindow != C.IndexUnset;
                            if (haveResumePosition)
                            {
                                Player.SeekTo(resumeWindow, resumePosition);
                            }

                            return;
                        }
                    }

                    if (videoSource == null)
                    {
                        if (!string.IsNullOrEmpty(videoUrL))
                        {
                            if (videoUrL.Contains("youtube") || videoUrL.Contains("Youtube") || videoUrL.Contains("youtu"))
                            {
                                Task.Run(async() =>
                                {
                                    var newurl  = await VideoInfoRetriever.GetEmbededVideo(Videodata.source);
                                    videoSource = CreateDefaultMediaSource(Android.Net.Uri.Parse(newurl));
                                });
                            }
                            else
                            {
                                videoSource = CreateDefaultMediaSource(Android.Net.Uri.Parse(videoUrL));

                                simpleExoPlayerView.Player = Player;
                                Player.Prepare(videoSource);
                                Player.AddListener(PlayerLitsener);
                                Player.PlayWhenReady = true;

                                bool haveResumePosition = resumeWindow != C.IndexUnset;
                                if (haveResumePosition)
                                {
                                    Player.SeekTo(resumeWindow, resumePosition);
                                }
                            }
                        }
                    }
                    else
                    {
                        simpleExoPlayerView.Player = Player;
                        Player.Prepare(videoSource);
                        Player.AddListener(PlayerLitsener);
                        Player.PlayWhenReady = true;

                        bool haveResumePosition = resumeWindow != C.IndexUnset;
                        if (haveResumePosition)
                        {
                            Player.SeekTo(resumeWindow, resumePosition);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Crashes.TrackError(exception);
            }
        }