Esempio n. 1
0
        private static void InnerShow(string absolutePath, int _displayMonitor)
        {
            ForeachVideoRenders((_videoRender, screen, index) =>
            {
                if (_displayMonitor == index || _displayMonitor < 0)
                {
                    if (_videoRender == null || _videoRender.RenderDisposed)
                    {
                        Execute.OnUIThread(() =>
                        {
                            _videoRender = new VideoRender();
                            _videoRender.Init(screen);

                            InnerApplyVideoAspect(_videoRender, VideoAspect, screen);

                            bool ok = LiveWallpaperEngineManager.Show(_videoRender, screen);
                            if (!ok)
                            {
                                LiveWallpaperEngineManager.Close(_videoRender);
                                System.Windows.MessageBox.Show("巨应壁纸貌似不能正常工作,请关闭杀软重试");
                            }
                            else
                            {
                                _videoRenders[index] = _videoRender;
                            }
                        });
                    }
                }
                _videoRender?.Play(absolutePath);
                if (index == _audioSourceMonitor)
                {
                    _videoRender?.Mute(false);
                }
            });
        }
Esempio n. 2
0
        private void btnVideo_Click(object sender, RoutedEventArgs e)
        {
            LiveWallpaperEngineManager.UIDispatcher = Dispatcher;
            using (var openFileDialog = new System.Windows.Forms.OpenFileDialog())
            {
                openFileDialog.Filter = "All files (*.*)|*.*";

                if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    ForeachVideoRenders((renderItem, screen) =>
                    {
                        bool returnNew = false;
                        if (renderItem == null || renderItem.RenderDisposed)
                        {
                            returnNew  = true;
                            renderItem = new VideoRender();
                            renderItem.Init(screen);
                            bool ok = LiveWallpaperEngineManager.Show(renderItem, screen);
                            if (!ok)
                            {
                                renderItem.CloseRender();
                                MessageBox.Show(ok.ToString());
                            }
                        }

                        string filePath = openFileDialog.FileName;
                        renderItem.Play(filePath);
                        if (returnNew)
                        {
                            return(renderItem);
                        }
                        return(null);
                    });
                }
            }
        }