Exemplo n.º 1
0
        /// <summary>
        /// When movie is loading
        /// </summary>
        ///<param name="e">MovieLoadingProgressEventArgs parameter</param>
        protected virtual void OnLoadingMovieProgress(MovieLoadingProgressEventArgs e)
        {
            EventHandler <MovieLoadingProgressEventArgs> handler = LoadingMovieProgress;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Report progress when a movie is loading and set to visible the progressbar, the cancel button and the LoadingText label
        /// </summary>
        /// <param name="sender">Sender object</param>
        /// <param name="e">MovieLoadingProgressEventArgs</param>
        private void OnLoadingMovieProgress(object sender, MovieLoadingProgressEventArgs e)
        {
            DispatcherHelper.CheckBeginInvokeOnUI(() =>
            {
                if (ProgressBar.Visibility == Visibility.Collapsed)
                {
                    ProgressBar.Visibility = Visibility.Visible;
                }

                if (StopLoadingMovieButton.Visibility == Visibility.Collapsed)
                {
                    StopLoadingMovieButton.Visibility = Visibility.Visible;
                }

                if (LoadingText.Visibility == Visibility.Collapsed)
                {
                    LoadingText.Visibility = Visibility.Visible;
                }

                ProgressBar.Value = e.Progress;

                // The percentage here is related to the buffering progress
                double percentage = e.Progress / Helpers.Constants.MinimumBufferingBeforeMoviePlaying * 100.0;

                if (percentage >= 100)
                {
                    percentage = 100;
                }

                if (e.DownloadRate >= 1000)
                {
                    LoadingText.Text = "Buffering : " + Math.Round(percentage, 0) + "%" + " ( " + e.DownloadRate / 1000 + " MB/s)";
                }
                else
                {
                    LoadingText.Text = "Buffering : " + Math.Round(percentage, 0) + "%" + " ( " + e.DownloadRate + " kB/s)";
                }
            });
        }