示例#1
0
        private void LoadVideo(MediaLoad mediaload)
        {
            this.mediaload = mediaload;

            //Обновляем резервную копию заданий
            UpdateTasksBackup();

            //Сбрасываем флаг ошибки Ависинта при новом открытии
            if (mediaload == MediaLoad.load) IsAviSynthError = false;

            //Чтоб позиция не сбрасывалась на ноль при включенном ScriptView;
            //а так-же НЕ сохраняем позицию после ошибки Ависинта в предыдущее открытие
            if (script_box.Visibility == Visibility.Collapsed && !IsAviSynthError)
            {
                oldpos = Position;
                if (avsPlayer != null && !avsPlayer.IsError)
                    avsFrame = avsPlayer.CurrentFrame;
            }

            // If we have ANY file open, close it and shut down DirectShow
            if (this.currentState != PlayState.Init)
                CloseClip();

            try
            {
                //Окно ошибок (если не закрылось в CloseClip)
                if (ErrBox.Visibility != Visibility.Collapsed)
                {
                    ErrBox.Child = null;
                    ErrBox.Visibility = Visibility.Collapsed;
                }

                //Пишем скрипт в файл
                AviSynthScripting.WriteScriptToFile(m.script, "preview");

                // Start playing the media file
                if (Settings.ScriptView)
                {
                    this.IsAudioOnly = false;
                    this.currentState = PlayState.Stopped;
                    script_box.Visibility = Visibility.Visible;
                    script_box.Text = m.script;
                    fps = Calculate.ConvertStringToDouble(m.outframerate);
                }
                else
                {
                    // Reset status variables
                    this.IsAudioOnly = true;
                    if (mediaload == MediaLoad.load)
                        this.currentState = PlayState.Stopped;

                    if (Settings.PlayerEngine == Settings.PlayerEngines.DirectShow)
                        PlayMovieInWindow(Settings.TempPath + "\\preview.avs");
                    else if (Settings.PlayerEngine == Settings.PlayerEngines.MediaBridge)
                        PlayWithMediaBridge(Settings.TempPath + "\\preview.avs");
                    else
                        PlayWithAvsPlayer(Settings.TempPath + "\\preview.avs");

                    this.Focus();
                    slider_pos.Focus(); //Переводит фокус на полосу прокрутки видео

                    //Запускаем таймер обновления позиции
                    if (timer != null) timer.Start();
                }
            }
            catch (Exception ex)
            {
                CloseClip();

                if (mediaload == MediaLoad.load && ex.Message.Contains("DirectX"))
                {
                    Message mess = new Message(this);
                    mess.ShowMessage(Languages.Translate("DirectX update required! Do it now?"),
                        Languages.Translate("Error"), Message.MessageStyle.YesNo);
                    if (mess.result == Message.Result.Yes)
                    {
                        m = null;
                        Process.Start(Calculate.StartupPath + "\\apps\\DirectX_Update\\dxwebsetup.exe");
                        Close();
                        return;
                    }
                }
                else
                {
                    ErrorException("LoadVideo: " + ex.Message, ex.StackTrace);
                    PreviewError(Languages.Translate("Error") + "...", Brushes.Red);
                }
            }

            //Делаем пункты меню активными
            if (mediaload == MediaLoad.load)
                MenuHider(true);

            textbox_name.Text = m.taskname;
        }
示例#2
0
        void PlayVideo(string file, MediaLoad mediaload)
        {
            try
            {
                this.mediaload = mediaload;

                if (this.currentState != PlayState.Init)
                    this.CloseClip();

                this.filepath = file;
                this.Title = Path.GetFileName(file) + " - " + Languages.Translate("loading") + "...";

                if (Settings.PlayerEngine == Settings.PlayerEngines.DirectShow)
                    this.PlayMovieInWindow();
                else
                    this.PlayWithMediaBridge();

                this.slider_pos.Focus();
                this.Title = Path.GetFileName(file) + " - WPF Video Player";

                //Запускаем таймер обновления позиции
                if (timer != null) timer.Start();
            }
            catch (Exception ex)
            {
                this.CloseClip();
                this.filepath = string.Empty;
                Win7Taskbar.SetProgressTaskComplete(this.Handle, TBPF.ERROR);
                System.Windows.MessageBox.Show("PlayVideo: " + ex.Message, Languages.Translate("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#3
0
        public void GetMediaLoadTest()
        {
            // Arrange

            // The URI for the test
            var requestUri = new Uri("https://localhost:445/api/v1/system/load");

            // Setup the dummy response
            MediaLoadResponse mediaLoadResponse = new MediaLoadResponse
            {
                MediaProcessingLoad = 10
            };

            // Setup serializer
            XmlSerializer serializer = new XmlSerializer(typeof(MediaLoadResponse));

            // Setup stringbuilder
            StringBuilder sb = new StringBuilder();

            // Setup xmlwriter settings
            XmlWriterSettings writerSettings = new XmlWriterSettings();

            // removes the - encoding="utf-16"
            writerSettings.OmitXmlDeclaration = true;

            // Setup xmlwriter
            XmlWriter writer = XmlWriter.Create(sb, writerSettings);

            // Remove the namespace
            XmlSerializerNamespaces ns = new XmlSerializerNamespaces();

            ns.Add("", "");

            // Serialise
            serializer.Serialize(writer, mediaLoadResponse, ns);

            // Set up the mock with the expected response
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(sb.ToString())
            };
            var mockHandler = new Mock <HttpClientHandler>();

            mockHandler
            .Protected()
            .Setup <Task <HttpResponseMessage> >(
                "SendAsync",
                ItExpr.Is <HttpRequestMessage>(message => message.RequestUri == requestUri),
                ItExpr.IsAny <CancellationToken>())
            .Returns(Task.FromResult(mockResponse));

            // Set up the HttpClient using the mock handler object
            HttpClient client = new HttpClient(mockHandler.Object);

            // Initialise an instance of the MediaLoad class for testing using the HttpClient
            MediaLoad mediaLoad = new MediaLoad(client, "https://localhost:445");

            // Act

            var mediaLoadResult = mediaLoad.Get().Result;

            // Assert

            Assert.True(mediaLoadResult == 10);
        }