コード例 #1
0
 public static void InitVideoForm(VideoForm form, VideoControl control)
 {
     m_CurrentForm = form;
     if (form != null && control != null)
     {
         InitCurrentVideoContrl(m_CurrentForm.videoControl1);
     }
     else
     {
         InitCurrentVideoContrl(control);
     }
 }
コード例 #2
0
        void DownloadNews(News news, string folder, string nativeSuffix, News sourceNews)
        {
            bool isTargetLanguage = nativeSuffix.Equals("en.");

            try
            {
                if (!string.IsNullOrEmpty(news.VideoSrc))
                {
                    WebDownloader.DownloadProgressDelegate dowloadProgress = new WebDownloader.DownloadProgressDelegate(progressDownloadForm.AssignProgress);
                    m_fileVideo = WebDownloader.Download(news.VideoSrc, folder, dowloadProgress, nativeSuffix + "mp4");
                    if (!string.IsNullOrEmpty(m_fileVideo))
                    {
                        //  news.AllLength = mp4info.FindLength_mciSend(m_fileVideo);
                        //AxWMPLib.AxWindowsMediaPlayer Player = new AxWMPLib.AxWindowsMediaPlayer();
                        VideoControl vc = new VideoControl();
                        vc.Player.URL = m_fileVideo;
                        // не помогает vc.Player.Ctlcontrols.pause(); // т.к. сразу играет
                        while ((int)vc.Player.playState == 9) // connecting
                        {
                            Application.DoEvents();
                        }
                        news.AllLength = (long)(vc.Player.currentMedia.duration * 1000);
                        vc.Player.URL  = "";
                        vc.Dispose();
                    }
                }
                else if (isTargetLanguage)
                {
                    // перейти на страницу чтобы самостоятельно скачать видео
                    MessageBox.Show(this, "Video not found. Try download it self.", Application.ProductName,
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    // открывать только если в диалоге выбрали Yes ???
                    //   Runner.OpenURL(url);
                }

                string fileExt     = "txt";
                string fileContent = news.HTMLContent;
                if (news.AllLength != -1) // т.е. известна длина видео
                {
                    fileExt     = "srt";
                    fileContent = SentenceParser.CreateSubtitles(news);
                }
                else // чтобы кол-во предложений былы синхронным добавим еще одно предложение
                {
                    fileContent = string.Format(VideoUnit.FirstSentence, news.URL) + "." + Environment.NewLine + fileContent;
                }

                if (!string.IsNullOrEmpty(news.HTMLContent))
                {
                    string fileName = folder + nativeSuffix + fileExt;
                    fileName = FileManager.CreateFile(fileName, fileContent);
                    if (isTargetLanguage)
                    {
                        this.m_FileSubtEn = fileName;
                        progressDownloadForm.EnSubtProgress = 100;
                    }
                    else
                    {
                        this.m_fileSubtNative = fileName;
                        progressDownloadForm.NativeSubtProgress = 100;
                    }
                }
            }
            catch
            {
                MessageBox.Show(this, "Please, try to select another news.", Application.ProductName,
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                progressDownloadForm.IsVideoWorng = true;
            }
        }
コード例 #3
0
 public static void InitCurrentVideoContrl(VideoControl cntrl)
 {
     m_CurrentVideoContrl = cntrl;
 }