public ViewRtsp(string rtspAddress) { InitializeComponent(); this.playAddress = rtspAddress; player = new VlcPlayer(this.axVLCPlugin21); //this.MaximumSize = new Size(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height); }
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 Window_Closing(object sender, CancelEventArgs e) { try { UltimaCommand.Stop.Execute(null, null); if (VlcPlayer.Inititalized) { VlcPlayer.Uninitialize(); } // Save filter to isolated storage if (_Filter != null) { using (FileStream stream = File.Create(_DefaultFilter)) { _Filter.Save(stream); } } } catch { // No sense in doing anything } }
void Play() { // Thread.Sleep(1000); this.Dispatcher.BeginInvoke(new Action(() => { VlcPlayer.Play(new FileInfo(_Path)); })); }
private void Window_Closing(object sender, CancelEventArgs e) { try { if (VlcPlayer.Inititalized) { VlcPlayer.Uninitialize(); } // Save filter to isolated storage if (_Filter != null) { using (IsolatedStorageFile storage = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly | IsolatedStorageScope.Domain, null, null)) { using (IsolatedStorageFileStream stream = storage.CreateFile(_DefaultFilter)) { _Filter.Save(stream); } } } } catch { // No sense in doing anything } }
private void PlayPause_Click(object sender, RoutedEventArgs e) { VlcPlayer player = Globals.Instance.VlcPlayer; if (player == null || File == null) { return; } try { if (player.IsPlaying) { player.Pause(); } else { if (!player.IsMediaLoaded) { player.LoadFromMemory(File.Data); } player.Play(); } } catch (Exception ex) { App.Window.ShowNotification(NotificationType.Error, ex); } }
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); }
/// <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; } } }
public ViewRtsp(string rtspAddress, TcpConnectJson.ScreenMonitor Screenmonitor, string IP, int Port) { InitializeComponent(); this.playAddress = rtspAddress; this.screenmonitor = Screenmonitor; this.ip = IP; this.port = Port; player = new VlcPlayer(this.axVLCPlugin21); }
private void vlcPlayer_StateChanged(object sender, Meta.Vlc.ObjectEventArgs <Meta.Vlc.Interop.Media.MediaState> e) { VlcPlayer vlcPlayer = sender as VlcPlayer; if (null == vlcPlayer || null == vlcPlayer.DataContext as ClassRoom) { return; } (vlcPlayer.DataContext as ClassRoom).VedioState = e.Value; }
private void launchVideoCallBtn_Click(object sender, EventArgs e) { vp = new VlcPlayer(this.axVLCPlugin21); //vlcPlayer初始化 vc = new VideoCall(MainForm.clientConnect, sevIP, localIP, localPort, remoteIP, remotePort, vp, camera, UserRole.teacher); //videoCall初始化 //之前这边错写成 VideoCall vc=new VideoCall(...),这样的话只是定义了一个与全局变量同名的局部变量,并对局部变量进行实例化, //但是全局变量vc仍然未实例化,导致下面recei()调用makeCallSuccess_A()函数中的vc为null,程序出错 vc.makeCall_A(); this.launchVideoCallBtn.Enabled = false; this.stopVideoCallBtn.Enabled = true; this.statusLbl.Text = "请求已发送,等待对方答复...."; }
private void UserControl_Unloaded(object sender, RoutedEventArgs e) { VlcPlayer player = Globals.Instance.VlcPlayer; if (player == null) { return; } player.TimeChanged -= new Action(Player_TimeChanged); player.Stopped -= new Action(Player_Stopped); }
protected override void Load(ContainerBuilder builder) { builder.RegisterType <VlcPlayer>() .AsSelf() .As <IMediaPlayer>() .SingleInstance(); builder.RegisterType <VlcDisplayViewModel>().As <IMediaDisplayViewModel>().SingleInstance(); builder.RegisterInstance(VlcPlayer.GetVolumeEndpoint()).SingleInstance(); AssemblySource.Instance.Add(typeof(VlcDisplayViewModel).Assembly); new VlcConfiguration().VerifyVlcPresent(); }
private void Button_Click_3(object sender, RoutedEventArgs e) { Uri uri = new Uri(path.Text); //String pathString = path.Text; VlcPlayer.BeginStop((ar) => { VlcPlayer.LoadMedia(uri.ToString()); VlcPlayer.Play(); }); }
/// <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; } } }
private void window_Loaded(object sender, RoutedEventArgs e) { InitialMessengers();//注册通知 Task.Run(() => { screenCaputre.ScreenCaputred += OnScreenCaputred; screenCaputre.ScreenCaputreCancelled += OnScreenCaputreCancelled; bool vlcCfg = VlcPlayer.VlcConfig(); LogHelper.log.Info("Vlc播放器配置:" + vlcCfg); }); ////FullScreenManager.RepairWpfWindowFullScreenBehavior(this);//适应全屏幕(窗口最小长宽限制会消失) //初始化UI UIInitial(); }
private void Player_TimeChangedSafe() { VlcPlayer player = Globals.Instance.VlcPlayer; if (player == null) { return; } _Suppress = true; Slider.Value = player.Time; Slider.Minimum = 0; Slider.Maximum = player.Length; }
protected override void OnElementChanged(ElementChangedEventArgs <View> e) { base.OnElementChanged(e); var vlcPlayerView = Element as VlcPlayerView; if ((vlcPlayerView == null) || (e.OldElement != null)) { return; } _videoView = new VlcPlayer(Context); _videoView.PlayerStateChanged += OnPlayerStateChanged; SetNativeControl(_videoView); }
private async Task RemoveCurrentImage() { await Task.Run(() => { VlcPlayer.Stop(); RecycleOption recycleOption = RecycleOption.DeletePermanently; if (SettingsViewModel.SendToRecycleBin) { recycleOption = RecycleOption.SendToRecycleBin; } FileSystem.DeleteFile(_imagePathList[_currentImageIndex].FullName, UIOption.OnlyErrorDialogs, recycleOption); Logging.LogInfo(recycleOption == RecycleOption.DeletePermanently ? "Deleted permanently: " : "Send to recycle bin: " + _imagePathList[_currentImageIndex].FullName); }); }
/// <summary> /// Constructor. /// </summary> /// <param name="control">The <see cref="VlcPlayer"/> with which media is played.</param> public VLCPlayer(VlcPlayer control) { this.player = control; this.player.Initialize(GetLibDirectory( ).FullName, "--no-osd", "--no-sub-autodetect-file"); this.player.VlcMediaPlayer.MediaChanged += PlayerOnMediaChanged; VideoFileExtensions = new[] { "mp4", "mkv", "avi", "divx", "f4v", "flv", "mov", "ogg", "ogm" }; AudioFileExtensions = new[] { "mp3", "wav", "flac" }; }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { _PlayImage = Resources["PlayerPlayImage"] as Image; _PauseImage = Resources["PlayerPauseImage"] as Image; PlayPause.Content = _PlayImage; VlcPlayer player = Globals.Instance.VlcPlayer; if (player == null) { return; } player.TimeChanged += new Action(Player_TimeChanged); player.Stopped += new Action(Player_Stopped); }
/// <summary> /// Loads a new video. /// </summary> private async Task LoadNewVideo() { try { VlcPlayer.RebuildPlayer(); await Task.Run(() => { VlcPlayer.Stop(); VlcPlayer.LoadMedia(_imagePathList[_currentImageIndex].FullName); VlcPlayer.Play(); CurrentImage = null; }); } catch (Exception ex) { HandleError(ex); } }
public MediaPlayerService() { var currentAssembly = Assembly.GetEntryAssembly(); var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName; // Default installation path of VideoLAN.LibVLC.Windows vlcLibDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "LibVlc", IntPtr.Size == 4 ? "win-x86" : "win-x86")); Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Background, new Action(() => { _vlcPlayer = new VlcPlayer(true) { EndBehavior = EndBehavior.Nothing, Stretch = System.Windows.Media.Stretch.Uniform , VlcOption = VlcOption, LibVlcPath = vlcLibDirectory.FullName }; })); }
/// <summary> /// Ctor. /// </summary> public MainViewModel() { SettingsViewModel = new SettingsViewModel(); StatisticViewModel = new StatisticViewModel(); if (SettingsViewModel.EnableStatisticTracking) { StatisticViewModel.Startups++; } _checkBoxFilter = ""; _imagePathFilter = ""; _imagePathList = new ObservableCollection <FileInfo>(); _directoryList = new ObservableCollection <SenpaiDirectory>(); IncludeFolderSubDirectories = true; DeleteImage = true; ResetCheckBoxes = true; LoadIgnoredPaths(); LoadFavoritePaths(); HotkeyPressedCommand = new KeyCommand(HotkeyPressed); TaskbarProgress = new TaskbarItemInfo() { ProgressState = TaskbarItemProgressState.Normal }; VlcPlayer = new VlcPlayer() { EndBehavior = EndBehavior.Repeat }; if (Environment.Is64BitProcess) { VlcPlayer.LibVlcPath = @"..\..\..\Libs\Vlc\lib\x64-libs"; } else { VlcPlayer.LibVlcPath = @"..\..\..\Libs\Vlc\lib\x86-libs"; } ReverseImageSearchButtonImage = "pack://application:,,,/SenpaiCopy;component/Resources/google-favicon.png"; _reverseImageSearchWorker = new BackgroundWorker(); _reverseImageSearchWorker.DoWork += new DoWorkEventHandler(GoogleReverseImageSearch); _dispatcher = Dispatcher.CurrentDispatcher; }
private void vlcPlayer_Initialized(object sender, EventArgs e) { VlcPlayer vlcPlayer = sender as VlcPlayer; if (null == vlcPlayer || null == vlcPlayer.DataContext as ClassRoom) { return; } (vlcPlayer.DataContext as ClassRoom).VlcPlayer = vlcPlayer; /* * System.Timers.Timer timer = new System.Timers.Timer(50) { AutoReset = false }; * timer.Elapsed += delegate { * timer.Dispose(); * vlcPlayer.LoadMedia((vlcPlayer.DataContext as ClassRoom).VedioAddress); * vlcPlayer.Play(); * vlcPlayer.IsMute = true; * }; */ System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); timer.Start(); timer.Interval = 1; timer.Tick += (s, f) => { timer.Stop(); vlcPlayer.LoadMedia((vlcPlayer.DataContext as ClassRoom).VedioAddress); vlcPlayer.Play(); }; timer.Start(); System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer(); timer1.Interval = 300; timer1.Tick += (s, f) => { timer1.Stop(); vlcPlayer.IsMute = true; }; timer1.Start(); }
public FoscamHDVideo(string url, string username, string password, ThreadSeparatedImage image, string libVlcPath = DEFAULT_LIBVLC_PATH, string[] vlcOptions = null) { 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(image.Dispatcher) { LibVlcPath = _libVlcPath, VlcOption = _vlcOptions }; _player.VideoSourceChanged += (sender, args) => { image.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { image.Source = args.NewVideoSource; })); }; }
private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { VlcPlayer player = Globals.Instance.VlcPlayer; if (player == null || File == null) { return; } try { if (!_Suppress && player.IsMediaLoaded) { player.Time = (int)Slider.Value; } _Suppress = false; } catch (Exception ex) { App.Window.ShowNotification(NotificationType.Error, ex); } }
internal void Setup(VlcPlayer player, Document doc, bool bAutoPlay = false) { _AssociatedPlayer = player; _MediaDocument = doc; // Validate Document Type if (MediaDocument.Type != DocumentType.Sound && MediaDocument.Type != DocumentType.Video && MediaDocument.Type != DocumentType.PlayList) { throw new InvalidOperationException("Documents set to MediaControls needs to be either sound or video or Playlists."); } // Get the document to be played SetupMedia(); // Update Binding _AssociatedPlayer.StateChanged += _AssociatedPlayer_StateChanged; // Auto play if (bAutoPlay) { ScheduleAutoplay(); } }
/// <summary> /// 语音讨论播放节点 /// </summary> /// <param name="item"></param> void academicReviewItem_ItemPlayClick(ConferenceAudioItem item) { try { //如果该语音节点包含语音url,说明包含语音文件 if (!string.IsNullOrEmpty(item.AudioUrl)) { if (this.vlcPlayer == null) { string pluginPath = System.Environment.CurrentDirectory + "\\plugins\\"; this.vlcPlayer = new VlcPlayer(pluginPath); } this.vlcPlayer.PlayFile(item.AudioUrl); } else { MessageBox.Show("播放的文件不存在或无效", "操作提示", MessageBoxButton.OK, MessageBoxImage.Information); } } catch (Exception ex) { LogManage.WriteLog(this.GetType(), ex); } }
//private bool first = true; //VlcPlayer vlc = null; #region Evaluate public void Evaluate(int SpreadMax) { for (int i = 0; i < SpreadMax; i++) { string path; this.FPinInPath.GetString(i, out path); //Check for update here, if path has not changed leave the file on bool needreset = false; bool add = false; if (this.players.Count < SpreadMax) { //New player, need to create needreset = true; add = true; } else { if (this.players[i] != null) { if (path != this.players[i].FileName) { this.players[i].Stop(); this.players[i].Dispose(); //this.players[i].DestroyDevice(); needreset = true; } } else { needreset = true; } } if (needreset) { if (File.Exists(path)) { if (add) { this.players.Add(new VlcPlayer()); } else { this.players[i] = new VlcPlayer(); } this.players[i].SetFileName(path); /*if (this.players[i].IsValid) * { * this.players[i].Start(); * }*/ } else { if (add) { this.players.Add(null); } else { //Just set a null here this.players[i] = null; } } } } if (this.players.Count > SpreadMax) { for (int i = SpreadMax; i < this.players.Count; i++) { this.players[i].Stop(); this.players[i].Dispose(); } this.players.RemoveRange(SpreadMax, this.players.Count - SpreadMax); } this.FTextureOut.SliceCount = SpreadMax; //Now we can set all play/loop/seek stuff for (int i = 0; i < SpreadMax; i++) { if (this.players[i] != null) { if (this.players[i].IsValid) { double dbldoseek; this.FPinInDoSeek.GetValue(i, out dbldoseek); if (dbldoseek > 0.5) { double seekpos; this.FPinInSeekPos.GetValue(i, out seekpos); //Seek in milliseconds this.players[i].SetPosition(Convert.ToSingle(seekpos)); } double dblstart; this.FPinInStart.GetValue(0, out dblstart); if (dblstart > 0.5) { this.players[i].SetPosition(0.0f); } double dblplay, dblloop, dblspeed, dblvolume; this.FPinInPlay.GetValue(i, out dblplay); this.FPinInLoop.GetValue(i, out dblloop); this.FPinInSpeed.GetValue(i, out dblspeed); this.FPinInVolume.GetValue(i, out dblvolume); this.players[i].Play = dblplay > 0.5; this.players[i].Loop = dblloop > 0.5; this.players[i].SetSpeed((float)dblspeed); this.players[i].SetVolume((float)dblvolume); } } if (this.FTextureOut[i] == null) { this.FTextureOut[i] = new DX11Resource <DX11DynamicTexture2D>(); } } //Process all outputs this.FPinOutPosition.SliceCount = this.players.Count; this.FPinOutFPS.SliceCount = this.players.Count; this.FPinOutDuration.SliceCount = this.players.Count; this.FPinOutValid.SliceCount = this.players.Count; this.FSizeOut.SliceCount = this.players.Count * 2; for (int i = 0; i < SpreadMax; i++) { if (this.players[i] != null) { if (this.players[i].IsValid) { VlcPlayer v = this.players[i]; v.GetStatus(); this.FPinOutFPS.SetValue(i, v.Fps); this.FPinOutDuration.SetValue(i, v.Duration); this.FPinOutPosition.SetValue(i, v.Position); this.FPinOutValid.SetValue(i, Convert.ToDouble(v.IsValid)); this.FSizeOut[i * 2] = v.Width; this.FSizeOut[i * 2 + 1] = v.Height; } else { this.FPinOutFPS.SetValue(i, -1); this.FPinOutDuration.SetValue(i, -1); this.FPinOutPosition.SetValue(i, -1); this.FPinOutValid.SetValue(i, -1); this.FSizeOut[i * 2] = -1; this.FSizeOut[i * 2 + 1] = -1; } } else { this.FPinOutFPS.SetValue(i, 0); this.FPinOutDuration.SetValue(i, 0); this.FPinOutPosition.SetValue(i, 0); this.FPinOutValid.SetValue(i, 0); this.FSizeOut[i * 2] = -1; this.FSizeOut[i * 2 + 1] = -1; } } }
private void StarterWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { HideLoading(); if (e.Error != null) { ShowNotification(NotificationType.Error, e.Error); return; } // Set filter _Filter.Initialize(); FilterView.Filter = _Filter; if (_Filter != null && File.Exists(_DefaultFilter)) { using (FileStream stream = File.Open(_DefaultFilter, FileMode.Open)) { try { _Filter.Load(stream); } catch { ShowNotification(NotificationType.Warning, "Could not load filter table, using a new one..."); } } } if (Globals.Instance.LegacyClientFolder != null) { ShowNotification(NotificationType.Info, String.Format("Detected classic client in folder '{0}'", Globals.Instance.LegacyClientFolder)); } if (Globals.Instance.EnhancedClientFolder != null) { ShowNotification(NotificationType.Info, String.Format("Detected enhanced client in folder '{0}'", Globals.Instance.EnhancedClientFolder)); } if (Globals.Instance.VlcInstallationFolder != null) { ShowNotification(NotificationType.Info, String.Format("Detected VLC player version '{0}'", VlcPlayer.GetVersion(Globals.Instance.VlcInstallationFolder))); } else { ShowNotification(NotificationType.Warning, "VLC player not installed. Some features will not be supported."); } if (Globals.Instance.ItemDefinitions != null && Globals.Instance.ItemProperties != null) { LootAnalyzerButton.IsEnabled = true; } }