private void TryToCreateClient() { if (myHandle == IntPtr.Zero) { return; } string path = string.IsNullOrEmpty(myVlcLibPath) ? AppDomain.CurrentDomain.BaseDirectory : myVlcLibPath; if (!File.Exists(Path.Combine(path, "libvlc.dll")) || !File.Exists(Path.Combine(path, "libvlccore.dll"))) { return; } myClient = new VideoLanClient(path); myClient.PluginPath = Path.Combine(path, "plugins"); myPlayer = myClient.CreateMediaPlayer(myHandle); myPlayer.Audio.Volume = Volume; myPlayer.Audio.Mute = Mute; //todo //myPlayer.PositionChanged += // delegate(object sender, VlcPositionChangedEventArgs e) // { // Position = e.Position; // }; myPlayer.StateChanged += delegate(object sender, VlcStateChangedEventArgs e) { if (e.NewState == VlcState.Ended) { Position = 0; } }; }
protected override void Dispose(bool disposing) { if (myVlcMediaPlayer != null) { UnregisterEvents(); if (IsPlaying) Stop(); myVlcMediaPlayer.Dispose(); myVlcMediaPlayer = null; base.Dispose(disposing); GC.SuppressFinalize(this); } }
internal VlcMedia(VlcMediaPlayer player, FileInfo file, params string[] options) #if NET20 : this(player, VlcMediaInstanceExtensions.AddOptionToMedia(player.Manager.CreateNewMediaFromPath(file.FullName), player.Manager, options)) #else : this(player, player.Manager.CreateNewMediaFromPath(file.FullName).AddOptionToMedia(player.Manager, options))
protected override void Dispose(bool disposing) { if (!disposed) { if (disposing) { if (myVlcMediaPlayer != null) { UnregisterEvents(); if (IsPlaying) Stop(); myVlcMediaPlayer.Dispose(); } myVlcMediaPlayer = null; base.Dispose(disposing); } disposed = true; } }
internal VlcMedia(VlcMediaPlayer player, VlcMediaInstance mediaInstance) { MediaInstance = mediaInstance; myVlcMediaPlayer = player; }
internal VlcMedia(VlcMediaPlayer player, Stream stream, params string[] options) : this(player, player.Manager.CreateNewMediaFromStream(stream).AddOptionToMedia(player.Manager, options)) { }
internal VlcMedia(VlcMediaPlayer player, string mrl, params string[] options) : this(player, player.Manager.CreateNewMediaFromLocation(mrl).AddOptionToMedia(player.Manager, options)) { }
internal VlcMedia(VlcMediaPlayer player, Uri uri, params string[] options) : this(player, player.Manager.CreateNewMediaFromLocation(uri.AbsoluteUri).AddOptionToMedia(player.Manager, options)) { }
internal VlcMedia(VlcMediaPlayer player, FileInfo file, params string[] options) : this(player, player.Manager.CreateNewMediaFromPath(file.FullName).AddOptionToMedia(player.Manager, options)) { }
public void EndInit() { if (IsInDesignMode() || myVlcMediaPlayer != null) return; if (VlcLibDirectory == null && (VlcLibDirectory = OnVlcLibDirectoryNeeded()) == null) { throw new Exception("'VlcLibDirectory' must be set."); } myVlcMediaPlayer = new VlcMediaPlayer(VlcLibDirectory); myVlcMediaPlayer.VideoHostControlHandle = Handle; RegisterEvents(); }