public void Connect(string url, string username, string password, string libVlcPath = DEFAULT_LIBVLC_PATH, string[] vlcOptions = null) { if (Player != null && Player.IsLoaded) { Player.Stop(); } string urlPrefix = "rtsp://" + username + ":" + password + "@"; _url = url.Replace("http://", urlPrefix).Replace("https://", urlPrefix); _url += VIDEO_RELATIVE_URL; _libVlcPath = libVlcPath ?? DEFAULT_LIBVLC_PATH; _vlcOptions = vlcOptions ?? DEFAULT_VLC_OPTIONS; Player = new VlcPlayer(DisplayImage.Dispatcher) { LibVlcPath = _libVlcPath, VlcOption = _vlcOptions }; Player.Initialize(@"..\..\libvlc", new string[] { "-I", "dummy", "--ignore-config", "--no-video-title" }); Player.VideoSourceChanged += (sender, args) => { DisplayImage.Dispatcher.BeginInvoke(new Action(() => { DisplayImage.Source = args.NewVideoSource; })); }; Player.LoadMedia(new Uri(_url)); Player.Play(); }
private void InitializeVLC(ref Image i) { //Player Settings string startupPath = System.IO.Directory.GetCurrentDirectory(); var vlcPath = Utils.GetWinVlcPath(); if (Utils.IsWindowsOs()) { Directory.SetCurrentDirectory(vlcPath); } vlcPlayer = new VlcPlayer(i.Dispatcher); vlcPlayer.Initialize(vlcPath, new string[] { "-I", "dummy", "--ignore-config", "--no-video-title" }); i.Source = vlcPlayer.VideoSource; i.Stretch = Stretch.Fill; vlcPlayer.EndBehavior = EndBehavior.Nothing; vlcPlayer.VideoSourceChanged += PlayerOnVideoSourceChanged; vlcPlayer.VlcMediaPlayer.EndReached += OnEndReached; timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(1); timer.Tick += new EventHandler(timer_Tick); player.VolumeValue = vlcPlayer.Volume; player.StopEnabled = false; player.PauseEnabled = false; //End Player Settings //Restore default path after vlc initialization Directory.SetCurrentDirectory(startupPath); }
private void Window2_Loaded(object sender, RoutedEventArgs e) { Loaded -= Window2_Loaded; CurrentPlayer.Initialize(@"Contents\LibVlc", new string[] { "-I", "--dummy", "--ignore-config", "--no-video-title", "--no-sub-autodetect-file" }); CurrentPlayer.EndBehavior = EndBehavior.Repeat; WebPageViewer cefWeb = new WebPageViewer("http://i.y.qq.com/v8/fcg-bin/v8_cp.fcg?channel=first&format=html&page=index&tpl=v12"); this.al.Children.Add(cefWeb); Button btn = new Button(); btn.Width = 100; btn.Height = 30; btn.Background = new SolidColorBrush(Colors.Red); btn.Click += Btn_Click; this.al.Children.Add(btn); //Button btn1 = new Button(); //btn1.Margin = new Thickness(100,0,0,0); //btn1.Width = 100; //btn1.Height = 30; //btn1.Background = new SolidColorBrush(Colors.Green); //btn1.Click += Btn1_Click; ; //this.al.Children.Add(btn1); }
/// <summary> /// Constructs a new instance of Globals. /// </summary> public Globals() { // Register packets UltimaPacket.RegisterPackets(); // Generators _ItemDefinitions = new UltimaItemDefinitions(); _ItemProperties = new UltimaItemProperties(); // Get enhanced client folder _LegacyClientFolder = SpyHelper.ClassicClientFolder; if (_LegacyClientFolder != null) { string clilocFilePath = Path.Combine(_LegacyClientFolder, "Cliloc.enu"); if (File.Exists(clilocFilePath)) { _Clilocs = UltimaStringCollection.FromFile(clilocFilePath); } InitializeLegacyAssets(_LegacyClientFolder); } _EnhancedClientFolder = SpyHelper.EnhancedClientFolder; if (_EnhancedClientFolder != null) { string clilocPackage = Path.Combine(_EnhancedClientFolder, "string_collection.uop"); if (File.Exists(clilocPackage)) { _Clilocs = UltimaStringCollection.FromPackage(clilocPackage); } if (_LegacyAssets == null) { InitializeEnhancedAssets(_EnhancedClientFolder); } } // Initialize VLC player _VlcInstallationFolder = VlcPlayer.DefaultInstallationFolder; if (!String.IsNullOrEmpty(_VlcInstallationFolder)) { try { VlcPlayer.Initialize(_VlcInstallationFolder); _VlcPlayer = new VlcPlayer(); } catch { _VlcInstallationFolder = null; } } }