コード例 #1
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                BackgroundProcessData currentData = e.Argument as BackgroundProcessData;
                if (currentData.CurrentVideoInfo != null)
                {
                    VideoInfo currentVideoInfo = currentData.CurrentVideoInfo;
                    currentVideoInfo.WatchCount++;
                    backgroundWorker1.ReportProgress(50, currentData);

                    string tempDirectory = Path.Combine(Path.GetTempPath(), "Temp");
                    Directory.CreateDirectory(tempDirectory);
                    backgroundWorker1.ReportProgress(97, currentData);

                    string tempFilePath = Path.Combine(tempDirectory, Path.GetFileName(currentData.OrignalVideoPath));
                    tempFileList.Add(tempFilePath);
                    Cryptograph.DecryptFile(currentData.OrignalVideoPath, tempFilePath);
                    currentData.DecryptedVideoPath = tempFilePath;
                    backgroundWorker1.ReportProgress(99, currentData);


                    SaveWatchedVideoCountOnFireBase(currentVideoInfo.VideoName, currentVideoInfo.WatchCount);
                    currentData.DecryptedVideoPath = "";
                    backgroundWorker1.ReportProgress(100, currentData);
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex, ex.Message, false);
                throw;
            }
        }
コード例 #2
0
        private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            try
            {
                BackgroundProcessData currentData = e.UserState as BackgroundProcessData;
                // Change the value of the ProgressBar
                progressBar1.Value = e.ProgressPercentage;
                if (currentData != null && currentData.State == BackgroundAppState.DecryptingVideoToPlay && currentData.DecryptedVideoPath != "")
                {
                    progressBar1.Visible           = false;
                    this.CurrentVideoInfo          = currentData.CurrentVideoInfo;
                    this.axWindowsMediaPlayer1.URL = currentData.DecryptedVideoPath;
                    //this.axWindowsMediaPlayer1.stretchToFit = true;
                    //lblWelcome.Text = string.Format("{0}", this.CurrentVideoInfo.Subject);
                    lblWelcome.Text = string.Format("{0}", this.CurrentVideoInfo.Book);

                    lblWatchCount.Text      = string.Format("Watch Count: {0} Times", currentData.CurrentVideoInfo.WatchCount);
                    this.lblFileName.Text   = Path.GetFileNameWithoutExtension(currentData.CurrentVideoInfo.VideoFullUrl);
                    _lastPlayedVideoFullUrl = currentData.CurrentVideoInfo.VideoFullUrl;
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex, ex.Message, false);
                throw;
            }
        }
コード例 #3
0
        private void PlayEncryptedVideo(string videoUrl)
        {
            try
            {
                if (ValidateLicense() == false || backgroundWorker1.IsBusy)
                {
                    return;
                }
                // this.axWindowsMediaPlayer1.URL = "";

                progressBar1.Visible = true;

                VideoInfo currentVideoInfo = CurrentVideoInfo = this.ClientInfoObject.VideoInfoList.First(i => i.VideoFullUrl.ToLower().Equals(videoUrl.ToLower()));

                BackgroundProcessData backgroundProcessData = new BackgroundProcessData();
                backgroundProcessData.CurrentVideoInfo = currentVideoInfo;
                backgroundProcessData.OrignalVideoPath = videoUrl;
                backgroundProcessData.State            = BackgroundAppState.DecryptingVideoToPlay;

                if (backgroundWorker1.IsBusy == true)
                {
                    backgroundWorker1.CancelAsync();
                }

                while (backgroundWorker1.IsBusy == true)
                {
                    // backgroundWorker1.CancelAsync();
                }
                backgroundWorker1.RunWorkerAsync(backgroundProcessData);

                //VideoInfo currentVideoInfo = this.ClientInfoObject.VideoInfoList.First(i => i.VideoFullUrl.ToLower().Equals(videoUrl.ToLower()));
                //currentVideoInfo.WatchCount++;
                ////string tempDirectory = Path.Combine(Path.GetDirectoryName(this.NextVideoFileList[0]), "Temp");
                //string tempDirectory = Path.Combine(Path.GetTempPath(), "Temp");
                //Directory.CreateDirectory(tempDirectory);
                //string tempFilePath = Path.Combine(tempDirectory, Path.GetFileName(videoUrl));
                //tempFileList.Add(tempFilePath);
                //Cryptograph.DecryptFile(videoUrl, tempFilePath);
                //this.axWindowsMediaPlayer1.URL = tempFilePath;
                //lblWelcome.Text = string.Format("{0}", currentVideoInfo.Subject);// string.Format("{0}, {1}, {2}", currentVideoInfo.ClassName, currentVideoInfo.SeriesName, currentVideoInfo.Subject);
                //lblWatchCount.Text = string.Format("Watch Count: {0} Times", currentVideoInfo.WatchCount);

                //   backgroundWorker1.RunWorkerAsync(videoUrl);
            }
            catch (Exception ex)
            {
                progressBar1.Visible = false;
                ExceptionHandler.HandleException(ex, "", false);
            }
        }