public override bool Play(string strFile)
        {
            url = strFile;

            VlcContext.StartupOptions.IgnoreConfig = true;
            VlcContext.StartupOptions.AddOption("--no-video-title-show");
            VlcContext.StartupOptions.AddOption("--http-caching=" + OnlineVideos.MediaPortal1.PluginConfiguration.Instance.wmpbuffer);
            //VlcContext.StartupOptions.LogOptions.LogInFile = true;
            //VlcContext.StartupOptions.LogOptions.Verbosity = VlcLogVerbosities.Standard;
            //VlcContext.StartupOptions.LogOptions.LogInFilePath = Path.Combine(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Log), "vlc-onlinevideos.log");
            if (IsInstalled)
            {
                VlcContext.LibVlcDllsPath = vlcPath;
                VlcContext.LibVlcPluginsPath = Path.Combine(vlcPath, "plugins");
            }

            vlcCtrl = new VlcControl();
            GUIGraphicsContext.form.Controls.Add(vlcCtrl);
            vlcCtrl.Enabled = false;

            vlcCtrl.PositionChanged += vlcCtrl_PositionChanged;
            vlcCtrl.EncounteredError += vlcCtrl_EncounteredError;

            media = new PathMedia(strFile);

            vlcCtrl.Play(media);

            GUIPropertyManager.SetProperty("#TV.Record.percent3", 0.0f.ToString()); // set to 0, as this player doesn't support download progress reporting

            GUIWaitCursor.Init(); GUIWaitCursor.Show(); // init and show the wait cursor while buffering

            return true;
        }
 void vlcCtrl_PositionChanged(VlcControl sender, VlcEventArgs<float> e)
 {
     playPosition = e.Data;
 }
        private void PlayInternal(PlayOptions options)
        {
            EnsureMediaPlayerCreated();

            CurrentPlaylistIndex = 0;
            CurrentPlayOptions = options;

            _playlist = options.Items.ToList();
            _isPaused = false;

            var path = options.Items.First().Path;

            try
            {
                //var media = new PathMedia(@"D:\\Video\\TV\\30 Rock\\Season 1\\30 Rock - 1x02 - The Aftermath.mkv");
                var media = path.StartsWith("http", StringComparison.OrdinalIgnoreCase) ?
                    (MediaBase)new LocationMedia(path) :
                    (MediaBase)new PathMedia(path);

                //media.StateChanged +=
                //    delegate(MediaBase s, VlcEventArgs<States> args)
                //    {
                //        if (args.Data == States.Ended)
                //        {
                //            var subItems = media.SubItems;
                //            if (subItems.Count > 0)
                //            {
                //                _vlcControl.Play(subItems[0]);
                //            }
                //        }
                //    };
                //media.MediaSubItemAdded +=
                //    delegate(MediaBase s, VlcEventArgs<MediaBase> args)
                //    {
                //        _vlcControl.Media = args.Data;
                //        _vlcControl.Play();
                //    };

                _vlcControl = new VlcControl();

                _vlcControl.Media = media;
                _vlcControl.PlaybackMode = PlaybackModes.Loop;
                _vlcControl.Stopped += _vlcControl_Stopped;
                _vlcControl.Paused += _vlcControl_Paused;
                _vlcControl.Playing += _vlcControl_Playing;
                _vlcControl.Play();

                _vlcControl.SetHandle(_hiddenWindow.Form.Handle);

                _userInput.GlobalKeyDown += _userInput_KeyDown;
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Error beginning playback", ex);

                DisposePlayer();
            }
        }
Beispiel #4
0
 private void OnLoaded(object sender, RoutedEventArgs e)
 {
     var vlcControl = new VlcControl();
     var rstpAddress = "rtsp://" + Address + "/snl/live/1/1/";
     var locationMedia = new LocationMedia(rstpAddress);
     vlcControl.Media = locationMedia;
     _windowsFormsHost.Child = vlcControl;
 }
Beispiel #5
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.Window = ((材合成.ScreenWindow)(target));
                return;

            case 2:

            #line 32 "..\..\ScreenWindow.xaml"
                ((System.Windows.Controls.Border)(target)).MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.Header_MouseLeftButtonDown);

            #line default
            #line hidden
                return;

            case 3:

            #line 48 "..\..\ScreenWindow.xaml"
                ((System.Windows.Controls.Image)(target)).MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.HideWindow);

            #line default
            #line hidden
                return;

            case 4:
                this.winformhost = ((System.Windows.Forms.Integration.WindowsFormsHost)(target));
                return;

            case 5:
                this.VlcPlayer = ((Vlc.DotNet.Forms.VlcControl)(target));

            #line 55 "..\..\ScreenWindow.xaml"
                this.VlcPlayer.VlcLibDirectoryNeeded += new System.EventHandler <Vlc.DotNet.Forms.VlcLibDirectoryNeededEventArgs>(this.VlcPlayer_VlcLibDirectoryNeeded);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
Beispiel #6
0
            /**
             *
             * Initializes the UI and loads all the recording's data into RAM.
             *
             * @param string fileBaseName since there are two file for each recording (landmark- and video-data), the timestamp will be used to identify them
             * @param string type specifies the emotion-type
             * @param idx assigns an index to the DataSet
             */
            public DataSetView(string fileBaseName, string type, int idx)
            {
                initModules();
                index         = idx;
                videoFile     = fileBaseName + ".mp4";
                dataFile      = fileBaseName + "." + type;
                shortName     = fileBaseName.Substring(fileBaseName.LastIndexOf("\\"));
                faceRecording = FaceRecording.load(dataFile);

                vlcControl = new Vlc.DotNet.Forms.VlcControl();
                vlcControl.VlcLibDirectoryNeeded += new EventHandler <Vlc.DotNet.Forms.VlcLibDirectoryNeededEventArgs>(this.OnVlcControlNeedLibDirectory);
                ((System.ComponentModel.ISupportInitialize)(this.vlcControl)).EndInit();
                vlcControl.ImeMode  = System.Windows.Forms.ImeMode.NoControl;
                vlcControl.Location = new System.Drawing.Point(0, 0);
                arrange();
                vlcControl.VlcMediaplayerOptions = null;

                dataImage            = new Bitmap(dataPictureBox.Bounds.Width, dataPictureBox.Bounds.Height);
                dataPictureBox.Image = dataImage;

                pictureUpdate = delegate
                {
                    dataPictureBox.Image = dataImage;
                    dataPictureBox.Refresh();
                };

                Controls.Add(vlcControl);
                Controls.Add(dataPictureBox);
                vlcControl.SetMedia(new Uri(videoFile), null);
                vlcControl.Play();
                vlcControl.Pause();

                model.NullFace = faceRecording.getNullFace();

                arrange();
            }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.DahePlayer = ((材合成.MainWindow)(target));
                return;

            case 10:
                this.Min = ((System.Windows.Controls.Button)(target));

            #line 457 "..\..\MainWindow.xaml"
                this.Min.Click += new System.Windows.RoutedEventHandler(this.ButtonMin_Click);

            #line default
            #line hidden
                return;

            case 11:
                this.Close = ((System.Windows.Controls.Button)(target));

            #line 462 "..\..\MainWindow.xaml"
                this.Close.Click += new System.Windows.RoutedEventHandler(this.ButtonMin_Click);

            #line default
            #line hidden
                return;

            case 12:
                this.GridStepOne = ((System.Windows.Controls.Grid)(target));
                return;

            case 13:
                this.btnAdd = ((System.Windows.Controls.Button)(target));

            #line 496 "..\..\MainWindow.xaml"
                this.btnAdd.Click += new System.Windows.RoutedEventHandler(this.添加素材_Click);

            #line default
            #line hidden
                return;

            case 14:

            #line 500 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.ListBox)(target)).SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.ListBox_SelectionChanged);

            #line default
            #line hidden
                return;

            case 15:
                this.tbOutPutCount = ((System.Windows.Controls.TextBox)(target));
                return;

            case 16:
                this.btnOut = ((System.Windows.Controls.Button)(target));

            #line 544 "..\..\MainWindow.xaml"
                this.btnOut.Click += new System.Windows.RoutedEventHandler(this.合成视频_Click);

            #line default
            #line hidden
                return;

            case 17:
                this.GridStepTwo = ((System.Windows.Controls.Grid)(target));
                return;

            case 18:
                this.tbOutPut = ((System.Windows.Controls.TextBox)(target));
                return;

            case 19:

            #line 723 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Border)(target)).PreviewMouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.择导出路径_Click);

            #line default
            #line hidden
                return;

            case 20:

            #line 754 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.跳过_Click);

            #line default
            #line hidden
                return;

            case 21:
                this.btnCut = ((System.Windows.Controls.Button)(target));

            #line 758 "..\..\MainWindow.xaml"
                this.btnCut.Click += new System.Windows.RoutedEventHandler(this.剪切视频_Click);

            #line default
            #line hidden
                return;

            case 22:

            #line 775 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.返回上一步_Click);

            #line default
            #line hidden
                return;

            case 23:
                this.GridStepThree = ((System.Windows.Controls.Grid)(target));
                return;

            case 24:

            #line 791 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.返回上一步_Click);

            #line default
            #line hidden
                return;

            case 25:

            #line 816 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.跳过_Click);

            #line default
            #line hidden
                return;

            case 26:
                this.btnVeritalToHorizontal = ((System.Windows.Controls.Button)(target));

            #line 818 "..\..\MainWindow.xaml"
                this.btnVeritalToHorizontal.Click += new System.Windows.RoutedEventHandler(this.竖版转横版_Click);

            #line default
            #line hidden
                return;

            case 27:
                this.GridStepFour = ((System.Windows.Controls.Grid)(target));
                return;

            case 28:

            #line 849 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.返回上一步_Click);

            #line default
            #line hidden
                return;

            case 29:

            #line 964 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.跳过_Click);

            #line default
            #line hidden
                return;

            case 30:
                this.btnHorizontalToVertical = ((System.Windows.Controls.Button)(target));

            #line 966 "..\..\MainWindow.xaml"
                this.btnHorizontalToVertical.Click += new System.Windows.RoutedEventHandler(this.横版转竖版_Click);

            #line default
            #line hidden
                return;

            case 31:

            #line 981 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.RadioButton)(target)).PreviewMouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.SwitchChannel_MouseLeftButtonDown);

            #line default
            #line hidden
                return;

            case 32:
                this.rbImageFill = ((System.Windows.Controls.RadioButton)(target));

            #line 987 "..\..\MainWindow.xaml"
                this.rbImageFill.PreviewMouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.SwitchChannel_MouseLeftButtonDown);

            #line default
            #line hidden
                return;

            case 33:
                this.gridColorPad = ((System.Windows.Controls.Grid)(target));
                return;

            case 34:
                this.gridImagePad = ((System.Windows.Controls.Grid)(target));
                return;

            case 35:

            #line 1021 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Border)(target)).PreviewMouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.择导图片路径上_Click);

            #line default
            #line hidden
                return;

            case 36:

            #line 1029 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Border)(target)).PreviewMouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.择图片路径下_Click);

            #line default
            #line hidden
                return;

            case 37:
                this.GridStepFive = ((System.Windows.Controls.Grid)(target));
                return;

            case 38:

            #line 1079 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.返回上一步横或者竖_Click);

            #line default
            #line hidden
                return;

            case 39:

            #line 1164 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.跳过_Click);

            #line default
            #line hidden
                return;

            case 40:
                this.btn合成字幕 = ((System.Windows.Controls.Button)(target));

            #line 1168 "..\..\MainWindow.xaml"
                this.btn合成字幕.Click += new System.Windows.RoutedEventHandler(this.合成字幕_Click);

            #line default
            #line hidden
                return;

            case 41:
                this.GridStepSix = ((System.Windows.Controls.Grid)(target));
                return;

            case 42:

            #line 1195 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.返回上一步_Click);

            #line default
            #line hidden
                return;

            case 43:

            #line 1243 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Border)(target)).PreviewMouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.择水印图片_Click);

            #line default
            #line hidden
                return;

            case 44:

            #line 1256 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.跳过_Click);

            #line default
            #line hidden
                return;

            case 45:
                this.btn添加水印 = ((System.Windows.Controls.Button)(target));

            #line 1259 "..\..\MainWindow.xaml"
                this.btn添加水印.Click += new System.Windows.RoutedEventHandler(this.添加水印_Click);

            #line default
            #line hidden
                return;

            case 46:
                this.GridStepSeven = ((System.Windows.Controls.Grid)(target));
                return;

            case 47:

            #line 1286 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.返回上一步_Click);

            #line default
            #line hidden
                return;

            case 48:

            #line 1332 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.开始合成_Click);

            #line default
            #line hidden
                return;

            case 49:
                this.grid预览页 = ((System.Windows.Controls.Grid)(target));
                return;

            case 50:
                this.winformhost = ((System.Windows.Forms.Integration.WindowsFormsHost)(target));
                return;

            case 51:
                this.VlcPlayer = ((Vlc.DotNet.Forms.VlcControl)(target));

            #line 1381 "..\..\MainWindow.xaml"
                this.VlcPlayer.VlcLibDirectoryNeeded += new System.EventHandler <Vlc.DotNet.Forms.VlcLibDirectoryNeededEventArgs>(this.VlcPlayer_VlcLibDirectoryNeeded);

            #line default
            #line hidden
                return;

            case 52:

            #line 1386 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.ListBox)(target)).SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.ListBox_SelectionChanged);

            #line default
            #line hidden
                return;

            case 53:
                this.imgPlay = ((System.Windows.Controls.Image)(target));

            #line 1416 "..\..\MainWindow.xaml"
                this.imgPlay.PreviewMouseDown += new System.Windows.Input.MouseButtonEventHandler(this.PlayOrPause);

            #line default
            #line hidden
                return;

            case 54:
                this.imgPause = ((System.Windows.Controls.Image)(target));

            #line 1418 "..\..\MainWindow.xaml"
                this.imgPause.PreviewMouseDown += new System.Windows.Input.MouseButtonEventHandler(this.PlayOrPause);

            #line default
            #line hidden
                return;

            case 55:
                this.playSilder = ((System.Windows.Controls.Slider)(target));

            #line 1433 "..\..\MainWindow.xaml"
                this.playSilder.PreviewMouseDown += new System.Windows.Input.MouseButtonEventHandler(this.PlaySilder_PreviewMouseDown);

            #line default
            #line hidden
                return;

            case 56:
                this.tbTime = ((System.Windows.Controls.TextBox)(target));
                return;

            case 57:

            #line 1447 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.跳转指定秒_Click);

            #line default
            #line hidden
                return;

            case 58:
                this.imgPop = ((System.Windows.Controls.Image)(target));

            #line 1451 "..\..\MainWindow.xaml"
                this.imgPop.PreviewMouseDown += new System.Windows.Input.MouseButtonEventHandler(this.Image_PreviewMouseDown);

            #line default
            #line hidden
                return;

            case 59:
                this.VolPopup = ((System.Windows.Controls.Primitives.Popup)(target));

            #line 1454 "..\..\MainWindow.xaml"
                this.VolPopup.MouseLeave += new System.Windows.Input.MouseEventHandler(this.MenuPopup_MouseLeave);

            #line default
            #line hidden
                return;

            case 60:

            #line 1460 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Slider)(target)).ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.Slider_ValueChanged);

            #line default
            #line hidden
                return;

            case 61:
                this.VideoQualityPopup = ((System.Windows.Controls.Primitives.Popup)(target));

            #line 1466 "..\..\MainWindow.xaml"
                this.VideoQualityPopup.MouseLeave += new System.Windows.Input.MouseEventHandler(this.VideoQualityPopup_MouseLeave);

            #line default
            #line hidden

            #line 1467 "..\..\MainWindow.xaml"
                this.VideoQualityPopup.MouseEnter += new System.Windows.Input.MouseEventHandler(this.VideoQualityPopup_MouseEnter);

            #line default
            #line hidden
                return;

            case 62:
                this.lbPlayList = ((System.Windows.Controls.ListBox)(target));
                return;

            case 63:
                this.playSilderFPS = ((System.Windows.Controls.Slider)(target));

            #line 1511 "..\..\MainWindow.xaml"
                this.playSilderFPS.PreviewMouseDown += new System.Windows.Input.MouseButtonEventHandler(this.PlaySilder帧_PreviewMouseDown);

            #line default
            #line hidden
                return;

            case 64:
                this.tbFrame = ((System.Windows.Controls.TextBox)(target));
                return;

            case 65:

            #line 1517 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.跳转指定帧_Click);

            #line default
            #line hidden
                return;

            case 66:

            #line 1529 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.返回_Click);

            #line default
            #line hidden
                return;

            case 67:

            #line 1530 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.开始处理_Click);

            #line default
            #line hidden
                return;

            case 68:

            #line 1531 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.跳过_Click);

            #line default
            #line hidden
                return;

            case 69:
                this.grid提示 = ((System.Windows.Controls.Grid)(target));
                return;

            case 70:
                this.tbTitle = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 71:
                this.tbTip = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 72:

            #line 1561 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.打开所在文件夹_Click);

            #line default
            #line hidden
                return;

            case 73:

            #line 1563 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.返回主界面Click);

            #line default
            #line hidden
                return;

            case 74:
                this.borCannotControl = ((System.Windows.Controls.Border)(target));
                return;

            case 75:

            #line 1595 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click_停止);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
        void _vlcControl_Stopped(VlcControl sender, VlcEventArgs<EventArgs> e)
        {
            var playlist = _playlist.ToList();
            var index = CurrentPlaylistIndex;
            var ticks = CurrentPositionTicks;

            DisposePlayer();

            var media = index != -1 && playlist.Count > 0 ? playlist[index] : null;

            var args = new PlaybackStopEventArgs
            {
                Playlist = playlist,
                Player = this,
                EndingPlaylistIndex = index,
                EndingPositionTicks = ticks,
                EndingMedia = media
            };

            EventHelper.QueueEventIfNotNull(PlaybackCompleted, this, args, _logger);

            _playbackManager.ReportPlaybackCompleted(args);
        }
 void _vlcControl_Paused(VlcControl sender, VlcEventArgs<EventArgs> e)
 {
     OnPlayStateChanged();
     _isPaused = true;
 }
Beispiel #10
0
        public void Replay(DateTime checkInTime, bool blockUntiVideoExit = false)
        {
            if (isDisposed)
            {
                this.player = new VlcControl { Name = string.Format("{0}.{1}", addr.Line, addr.MachineAddr), Dock = DockStyle.Fill };
                this.Prepare();
                isDisposed = false;
            }

            CosnoleUtil.HideConsole();

            var startPos = Convert.ToInt64(Path.GetFileNameWithoutExtension(recPath));
            if (TimeUtil.ToTimestamp(checkInTime) < startPos)
            {
                new MediaPlayer(this, recPath, -1, REPLAY_DURATION).ShowDialog();
            }
            else
            {
                //rec is 1.5 secs slower than live movie
                new MediaPlayer(this, recPath, TimeUtil.ToTimestamp(checkInTime.AddSeconds(1.5)) - startPos, REPLAY_DURATION).ShowDialog();
            }
            

            //var proc = new Process();
            //proc.StartInfo.FileName = AppDomain.CurrentDomain.BaseDirectory + @"lib\vlc\vlc.exe";
            //var startPos = Convert.ToInt64(Path.GetFileNameWithoutExtension(recPath));
            //if (TimeUtil.ToTimestamp(checkInTime) < startPos)
            //    proc.StartInfo.Arguments = string.Format(" {0} --run-time=10 --play-and-exit", recPath);
            //else
            //    proc.StartInfo.Arguments = string.Format(" {0} --start-time={1} --run-time={2} --play-and-exit", recPath, TimeUtil.ToTimestamp(checkInTime) - startPos, REPLAY_DURATION);
            //proc.StartInfo.CreateNoWindow = true;
            //proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            //proc.Start();
            //if (blockUntiVideoExit) proc.WaitForExit();
        }
Beispiel #11
0
 public IPCamera(CameraAddress addr, LiveCameraMonitor monitor)
 {
     this.addr = addr;
     this.monitor = monitor;
     this.player = new VlcControl { Name = string.Format("{0}.{1}", addr.Line, addr.MachineAddr), Dock = DockStyle.Fill };
     this.Prepare();
 }
 public void LinkVLCPlayer(FrameworkElement host)
 {
     player = new VlcControl();
     (host as WindowsFormsHost).Child = player;
     dir = new DirectoryInfo(Properties.Settings.Default.MediaFolder);
     if (dir.Exists)
     {
         mediafiles = dir.GetFiles().Where(f => allowableMediaTypes.Contains(f.Extension)).ToList();
         videoFilesDirectoryWatcher = new FileSystemWatcher(dir.FullName);
         videoFilesDirectoryWatcher.Changed += new FileSystemEventHandler(videoFilesDirectoryWatcher_Changed);
         videoFilesDirectoryWatcher.Created += new FileSystemEventHandler(videoFilesDirectoryWatcher_Changed);
         videoFilesDirectoryWatcher.Deleted += new FileSystemEventHandler(videoFilesDirectoryWatcher_Changed);
         videoFilesDirectoryWatcher.IncludeSubdirectories = false;
         videoFilesDirectoryWatcher.EnableRaisingEvents = true;
     }
     if (mediafiles != null)
     {
         currentMedia = 0;
         CurrentFile = mediafiles[currentMedia];
         player.Media = new PathMedia(CurrentFile.FullName);
         StartPlayingMedia();
         updat = new DispatcherTimer();
         updat.Interval = TimeSpan.FromMilliseconds(100);
         updat.Tick += UpdateMediaWindow;
         updat.Start();
     }
 }
Beispiel #13
0
        void LoadRegularPage()
        {
            //panel
            comicPanel = new Panel();
            comicPanel.AutoSize = true;
            comicPanel.Width = REGULAR_COMIC_PANEL_WIDTH;
            comicPanel.MaximumSize = new Size(REGULAR_COMIC_PANEL_WIDTH, Int32.MaxValue);
            comicPanel.Location = new Point(mainPanel.Width / 2 - comicPanel.Width / 2, REGULAR_COMIC_PANEL_Y_OFFSET);
            comicPanel.BackColor = Color.FromArgb(REGULAR_COMIC_PANEL_COLOUR_R, REGULAR_COMIC_PANEL_COLOUR_G, REGULAR_COMIC_PANEL_COLOUR_B);
            mainPanel.Controls.Add(comicPanel);

            //title
            title = new GrowRich();
            title.Width = REGULAR_PAGE_TITLE_WIDTH;
            title.SelectionAlignment = HorizontalAlignment.Center;
            title.Font = new System.Drawing.Font("Courier New", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            title.Text = page.meta.title;
            comicPanel.Controls.Add(title);
            title.Location = new Point(comicPanel.Width / 2 - title.Width / 2, REGULAR_TITLE_Y_OFFSET);

            //content
            int currentHeight = !Enum.IsDefined(typeof(Writer.FullScreenFlashes), page.number) ? title.Location.Y + title.Height + REGULAR_TITLE_Y_OFFSET : 0;
            if (Parser.IsOpenBound(page.number))
            {
                flash = new WebBrowser();
                comicPanel.Controls.Add(flash);
                InitOpenbound();
                flash.Location = new Point(comicPanel.Width / 2 - flash.Width / 2, currentHeight);
                currentHeight += flash.Height;
                pageContainsFlash = true;
            }
            else
            {
                for (int i = 0; i < page.resources.Count(); i++)
                {
                    if (i == page.resources.Count() - 1 && Parser.Is2x(page.number) && page.resources != page.resources2)
                    {
                        currentHeight -= REGULAR_COMIC_PANEL_BOTTOM_Y_OFFSET;
                        continue;
                    }
                    if (page.resources[i].isInPesterLog)
                        continue;
                    if (!pageContainsFlash &&
                        ((page.number == 8848 || page.number == 8850) //special horizontal scroll
                        || !Parser.IsGif(page.resources[i].originalFileName)))
                    {
                        if (Path.GetExtension(page.resources[i].originalFileName) == ".mp4")
                        {
                            FVideoPlayer = TryInitVLC();
                            if (FVideoPlayer == null)
                                return;
                            var loc = WriteTempResource(ref page.resources[i]);
                            FVideoPlayer.Width = Width;
                            FVideoPlayer.Height = Height;
                            FVideoPlayer.SetMedia(new FileInfo(loc));
                            FVideoPlayer.Play();
                            Controls.Add(FVideoPlayer);
                            currentHeight += 750;
                        }
                        else
                        {
                            flash = new WebBrowser();
                            comicPanel.Controls.Add(flash);
                            InitFlashMovie(flash, page.resources[i]);

                            flash.Location = new Point(comicPanel.Width / 2 - flash.Width / 2, currentHeight);
                            currentHeight += flash.Height;
                            pageContainsFlash = true;
                        }
                       }
                    else if (Parser.IsGif(page.resources[i].originalFileName))
                    {

                        var tempPB = new GifStream();
                        tempPB.loc = new System.IO.MemoryStream(page.resources[i].data);
                        tempPB.gif = new PictureBox();
                        tempPB.gif.Image = Image.FromStream(tempPB.loc);
                        tempPB.gif.Width = tempPB.gif.Image.Width;
                        tempPB.gif.Height = tempPB.gif.Image.Height;
                        tempPB.gif.Location = new Point(comicPanel.Width / 2 - tempPB.gif.Width / 2, currentHeight);
                        comicPanel.Controls.Add(tempPB.gif);
                        currentHeight += tempPB.gif.Height;
                        if (i < page.resources.Count() - 1 || (page.resources[page.resources.Count() - 1].isInPesterLog && i == page.resources.Count() - 1))
                            currentHeight += REGULAR_COMIC_PANEL_BOTTOM_Y_OFFSET;
                        gifs.Add(tempPB);
                    }
                }
            }
            if (!Enum.IsDefined(typeof(Writer.FullScreenFlashes), page.number))
                currentHeight += REGULAR_SPACE_BETWEEN_CONTENT_AND_TEXT;

            //words
            int leftSide;
            if (page.meta.narr != null)
            {
                narrative = new GrowRich();
                narrative.Width = REGULAR_NARRATIVE_WIDTH;
                narrative.DetectUrls = true;
                narrative.SelectionAlignment = HorizontalAlignment.Center;
                narrative.Font = new System.Drawing.Font("Courier New", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                narrative.Text = page.meta.narr.text;
                narrative.ForeColor = System.Drawing.ColorTranslator.FromHtml(page.meta.narr.hexColour);
                var tmpl = narrative;
                if (page.meta.narr.subTexts.Count() != 0)
                    for (int j = 0; j < page.meta.narr.subTexts.Count(); ++j)
                    {
                        if (!page.meta.narr.subTexts[j].isImg && !page.meta.narr.subTexts[j].isLink)
                        {

                            //font change
                            tmpl.Select(page.meta.narr.subTexts[j].begin, page.meta.narr.subTexts[j].length);
                            if (page.meta.narr.subTexts[j].underlined)
                                tmpl.SelectionFont = new System.Drawing.Font("Courier New", 10.5F, System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                            tmpl.SelectionColor = System.Drawing.ColorTranslator.FromHtml(page.meta.narr.subTexts[j].colour);
                        }
                        else if (page.meta.narr.subTexts[j].isLink)
                        {
                            //so since rtf hyperlinks are broken to f**k we'll just improvise
                            var link = new GrowLinkLabel();
                            tmpl.Select(page.meta.narr.subTexts[j].begin, page.meta.narr.subTexts[j].length);
                            link.Text = tmpl.SelectedText;
                            link.Font = narrative.Font;
                            var inlineLink = page.meta.narr.subTexts[j].colour;
                            //for lack of a better place to put this snippet/lazyness'
                            if (page.number == (int)Writer.StoryBoundaries.EOHSB)
                                link.Click += (o, i) => { WakeUpMr((int)Writer.StoryBoundaries.HOMESTUCK_PAGE_ONE); };
                            else
                                link.Click += (o, i) => { System.Diagnostics.Process.Start(inlineLink); };
                            link.Width = narrative.Width;
                            link.Height = narrative.Height;
                            link.TextAlign = ContentAlignment.MiddleCenter;
                            conversations.Add(new LineOrPB(link));
                        }
                        else
                        {
                            //inline image

                            //what needs to happen here is we need to advance the text so that the image can fit in which should just be " " times some factor of the width of the image
                            //for now assume 1space = 10.5 pt = 14px
                            Parser.Resource inlineImg = Array.Find(page.resources, x => x.isInPesterLog == true && x.originalFileName == page.meta.narr.subTexts[j].colour);
                            var tmpPB = new GifStream();
                            tmpPB.loc = new MemoryStream(inlineImg.data);
                            tmpPB.gif = new PictureBox();
                            tmpPB.gif.Image = Image.FromStream(tmpPB.loc);

                            string spaces = "";
                            int needed = tmpPB.gif.Image.Width / 14;
                            for (int k = 0; k < needed; ++k)
                                spaces += " ";

                            tmpl.Text = tmpl.Text.Substring(0, page.meta.narr.subTexts[j].begin) + spaces + tmpl.Text.Substring(page.meta.narr.subTexts[j].begin);

                            //just dispose the picture while we are testing this
                            tmpPB.gif.Dispose();
                            tmpPB.loc.Dispose();

                        }
                    }
                leftSide = comicPanel.Width / 2 - narrative.Width / 2;
                narrative.Location = new Point(leftSide, currentHeight);

                currentHeight += narrative.Height;

                comicPanel.Controls.Add(narrative);

                foreach (var link in conversations)
                {
                    comicPanel.Controls.Add(link.GetControl());
                    link.GetControl().Location = narrative.Location;
                    link.GetControl().BringToFront();
                }
            }
            else
            {
                pesterlog = new Panel();
                pesterlog.AutoSize = true;
                pesterlog.Width = REGULAR_PESTERLOG_WIDTH;
                pesterlog.Height = REGULAR_PESTERLOG_HEIGHT;
                pesterlog.MinimumSize = new Size(REGULAR_PESTERLOG_WIDTH, REGULAR_PESTERLOG_HEIGHT);
                pesterlog.MaximumSize = new Size(REGULAR_PESTERLOG_WIDTH, Int32.MaxValue);
                pesterlog.BorderStyle = BorderStyle.FixedSingle;
                pesterlog.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;

                leftSide = comicPanel.Width / 2 - pesterlog.Width / 2;
                pesterlog.Location = new Point(leftSide, currentHeight);
                comicPanel.Controls.Add(pesterlog);

                pesterHideShow = new Button();
                pesterHideShow.FlatStyle = FlatStyle.Flat;
                pesterHideShow.AutoSize = true;
                pesterHideShow.Font = new System.Drawing.Font("Arial", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                pesterHideShow.Text = "Show " + page.meta.promptType;
                pesterHideShow.Click += pesterHideShow_Click;
                pesterLogVisible = false;
                pesterlog.Controls.Add(pesterHideShow);
                pesterHideShow.Location = new Point(pesterlog.Width / 2 - pesterHideShow.Width / 2, 2);

                pLMaxHeight = currentHeight + REGULAR_SPACE_BETWEEN_CONTENT_AND_TEXT;
                //log lines
                for (int i = 0; i < page.meta.lines.Count(); ++i)
                {
                    if (!page.meta.lines[i].isImg)
                    {
                        var tmpl = new GrowRich();
                        tmpl.Width = REGULAR_PESTERLOG_LINE_WIDTH;
                        tmpl.DetectUrls = true;
                        tmpl.MaximumSize = new Size(tmpl.Width, Int32.MaxValue);
                        tmpl.Font = new System.Drawing.Font("Courier New", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                        tmpl.BackColor = pesterlog.BackColor;   //can't change forecolour otherwise
                        tmpl.ForeColor = System.Drawing.ColorTranslator.FromHtml(page.meta.lines[i].hexColour);
                        tmpl.Text = "";

                        tmpl.Text += page.meta.lines[i].text;

                        if (page.meta.lines[i].subTexts.Count() != 0)
                            for (int j = 0; j < page.meta.lines[i].subTexts.Count(); ++j)
                            {
                                if (!page.meta.lines[i].subTexts[j].isImg && !page.meta.lines[i].subTexts[j].isLink)
                                {

                                    //font change
                                    tmpl.Select(page.meta.lines[i].subTexts[j].begin, page.meta.lines[i].subTexts[j].length);
                                    if (page.meta.lines[i].subTexts[j].underlined)
                                        tmpl.SelectionFont = new System.Drawing.Font("Courier New", 10.5F, System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                                    tmpl.SelectionColor = System.Drawing.ColorTranslator.FromHtml(page.meta.lines[i].subTexts[j].colour);
                                }
                                else if (page.meta.lines[i].subTexts[j].isLink)
                                {

                                    tmpl.Select(page.meta.lines[i].subTexts[j].begin, page.meta.lines[i].subTexts[j].length);
                                    tmpl.DetectUrls = true;
                                    tmpl.AppendText(page.meta.lines[i].subTexts[j].colour);
                                    Debugger.Break();
                                }
                                else
                                {
                                    //inline image

                                    //what needs to happen here is we need to advance the text so that the image can fit in which should just be " " times some factor of the width of the image
                                    //for now assume 1space = 10.5 pt = 14px
                                    Parser.Resource inlineImg = Array.Find(page.resources, x => x.isInPesterLog == true && x.originalFileName == page.meta.lines[i].subTexts[j].colour);
                                    var tmpPB = new GifStream();
                                    tmpPB.loc = new MemoryStream(inlineImg.data);
                                    tmpPB.gif = new PictureBox();
                                    tmpPB.gif.Image = Image.FromStream(tmpPB.loc);

                                    string spaces = "";
                                    int needed = tmpPB.gif.Image.Width / 14;
                                    for (int k = 0; k < needed; ++k)
                                        spaces += " ";

                                    tmpl.Text = tmpl.Text.Substring(0, page.meta.lines[i].subTexts[j].begin) + spaces + tmpl.Text.Substring(page.meta.lines[i].subTexts[j].begin);

                                    //just dispose the picture while we are testing this
                                    tmpPB.gif.Dispose();
                                    tmpPB.loc.Dispose();

                                }
                            }
                        tmpl.Location = new Point(pesterlog.ClientSize.Width / 2 - tmpl.Width / 2, pLMaxHeight - currentHeight);
                        pLMaxHeight += tmpl.Height;
                        conversations.Add(new LineOrPB(tmpl));
                    }
                    else
                    {
                        //find the resource
                        var tmpI = Array.Find(page.resources, x => x.isInPesterLog == true && x.originalFileName == page.meta.lines[i].text);
                        //TODO: Handle image lines ("SHE HAS WHAT????")
                        if (Parser.IsGif(tmpI.originalFileName))
                        {

                            var tempPB = new GifStream();
                            tempPB.loc = new System.IO.MemoryStream(tmpI.data);
                            tempPB.gif = new PictureBox();
                            tempPB.gif.Image = Image.FromStream(tempPB.loc);
                            tempPB.gif.Width = tempPB.gif.Image.Width;
                            tempPB.gif.Height = tempPB.gif.Image.Height;
                            tempPB.gif.Location = new Point(pesterlog.ClientSize.Width / 2 - REGULAR_PESTERLOG_LINE_WIDTH / 2, pLMaxHeight - currentHeight);
                            pLMaxHeight += tempPB.gif.Height;

                            conversations.Add(new LineOrPB(tempPB));
                        }
                        else
                        {
                            //there's problems
                            Debugger.Break(); //then let us bounce
                        }
                    }
                }

                currentHeight += pesterlog.Height;
                pLMinHeight = currentHeight;
                pLMaxHeight += REGULAR_SPACE_BETWEEN_CONTENT_AND_TEXT;
            }

            if (!Enum.IsDefined(typeof(Writer.FullScreenFlashes), page.number))
                currentHeight += REGULAR_SPACE_BETWEEN_CONTENT_AND_TEXT;

            //add 2x fake link

            if (Parser.Is2x(page.number) && page.resources != page.resources2)
            {
                var tempPB = new GifStream();
                tempPB.loc = new System.IO.MemoryStream(page.resources[page.resources.Count() - 1].data);
                tempPB.gif = new PictureBox();
                tempPB.gif.Image = Image.FromStream(tempPB.loc);
                tempPB.gif.Width = tempPB.gif.Image.Width;
                tempPB.gif.Height = tempPB.gif.Image.Height;
                tempPB.gif.Location = new Point(comicPanel.Width / 2 - tempPB.gif.Width / 2, currentHeight);
                comicPanel.Controls.Add(tempPB.gif);
                currentHeight += tempPB.gif.Height;
                gifs.Add(tempPB);
            }

            //next page
            if (page.number < db.lastPage && page.links != null)
            {
                for (int i = 0; i < page.links.Count(); i++)
                {
                    var linkPrefixn = new Label();
                    linkPrefixn.AutoSize = true;
                    linkPrefixn.Font = new System.Drawing.Font("Verdana", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    linkPrefixn.Text = REGULAR_LINK_PREFIX;
                    linkPrefixn.Location = new Point(leftSide, currentHeight);
                    comicPanel.Controls.Add(linkPrefixn);
                    linkPrefix.Add(linkPrefixn);

                    var nextn = new GrowLinkLabel();
                    nextn.Width = 600;
                    nextn.Font = new System.Drawing.Font("Verdana", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    nextn.Text = "    " + page.links[i].originalText;
                    nextn.Location = new Point(leftSide, currentHeight);
                    var tmpi = i;   //I really don't know how these labmdas work sometimes
                    if (Enum.IsDefined(typeof(Writer.PasswordPages), page.links[tmpi].pageNumber))
                        nextn.LinkClicked += HandleTereziPassword;
                    else
                        nextn.LinkClicked += (o, z) => { WakeUpMr(page.links[tmpi].pageNumber); };
                    comicPanel.Controls.Add(nextn);
                    next.Add(nextn);

                    linkPrefixn.BringToFront();
                    if (i < page.links.Count() - 1)
                        currentHeight += nextn.Height;
                }
            }

            comicPanel.Height = currentHeight + REGULAR_COMIC_PANEL_BOTTOM_PADDING;

            mainPanel.Height = comicPanel.Height + REGULAR_COMIC_PANEL_Y_OFFSET + REGULAR_COMIC_PANEL_BOTTOM_Y_OFFSET;

            if (page.meta.promptType == "CalibornLog")
                FixNarrativePrompt();

            RemoveControl(pageLoadingProgress);RemoveControl(progressLabel);
        }
Beispiel #14
0
 VlcControl TryInitVLC()
 {
     VlcControl ctl = new VlcControl();
     ctl.EndReached += (a, b) => {
         if (page.number < db.lastPage)
             WakeUpMr(page.number + 1);
         else
             goBack_Click(null, null);
     };
     ctl.Location = new Point(0, 0);
     ctl.Width = Width;
     ctl.Height = Height;
     ctl.BeginInit();
     for(;;)
     {
         ctl.VlcLibDirectory = new DirectoryInfo(Properties.Settings.Default.vlcLibFolder);
         try
         {
             ctl.EndInit();
             break;
         }
         catch
         {
             MessageBox.Show("Invalid VLC Library directory. Please select the folder which contains the 32-bit libvlc.dll");
             FolderBrowserDialog fbd = new FolderBrowserDialog();
             fbd.Description = "Select the folder which contains the 32-bit libvlc.dll";
             fbd.SelectedPath = Properties.Settings.Default.vlcLibFolder;
             if(fbd.ShowDialog() != DialogResult.OK)
                 return null;
             Properties.Settings.Default.vlcLibFolder = fbd.SelectedPath;
         }
     }
     return ctl;
 }
Beispiel #15
0
 void CleanComic()
 {
     RemoveControl(errorLabel);
     RemoveControl(title);
     foreach (var pic in gifs)
     {
         RemoveControl(pic.gif);
         pic.loc.Dispose();
     }
     gifs.Clear();
     foreach (var lp in linkPrefix)
         RemoveControl(lp);
     linkPrefix.Clear();
     foreach (var lp in next)
         RemoveControl(lp);
     next.Clear();
     if (monitorGameOver.IsBusy)
     {
         var tmp = flash;
         flash = null; //prevent progress report from changing colours
         RemoveControl(tmp);
         monitorGameOver.CancelAsync();
     }else
         RemoveControl(flash);
     RemoveControl(pesterHideShow);
     foreach (var line in conversations)
         line.Dispose();
     conversations.Clear();
     RemoveControl(pesterlog);
     RemoveControl(comicPanel);
     RemoveControl(FVideoPlayer);
     FVideoPlayer = null;
     if (x2Panel != null)
     {
         x2Panel.Kill();
         x2Panel = null;
     }
     if (openbound != null)
     {
         openbound.Dispose();
         openbound = null;
     }
     foreach (var p in tempFiles)
     {
         try
         {
             File.Delete(p);
         }
         catch { }
     }
     tempFiles.Clear();
 }
        void vlcCtrl_EncounteredError(VlcControl sender, VlcEventArgs<EventArgs> e)
        {
            string error = VlcContext.ErrorHandling.GetErrorMessage();
            GUIWindowManager.SendThreadCallbackAndWait((p1, p2, o) =>
            {
                Log.Instance.Warn("VLCPlayer Error: '{0}'", error);
                if (!bufferingDone && Initializing) GUIWaitCursor.Hide(); // hide the wait cursor if still showing
                MediaPortal.Dialogs.GUIDialogOK dlg_error = (MediaPortal.Dialogs.GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
                if (dlg_error != null)
                {
                    dlg_error.Reset();
                    dlg_error.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName);
					dlg_error.SetLine(1, Translation.Instance.Error);
                    dlg_error.SetLine(2, error);
                    dlg_error.DoModal(GUIWindowManager.ActiveWindow);
                }
                PlaybackEnded();
                return 0;
            }, 0, 0, null);
        }