/// <summary> /// 通过名称创建一个新的 VlcMedia /// </summary> /// <param name="vlc">Vlc 对象</param> /// <param name="name">媒体名称</param> public static VlcMedia CreateAsNewNode(Vlc vlc, String name) { GCHandle handle = GCHandle.Alloc(Encoding.UTF8.GetBytes(name), GCHandleType.Pinned); var madia = new VlcMedia(_createMediaAsNewNodeFunction.Delegate(vlc.InstancePointer, handle.AddrOfPinnedObject())); handle.Free(); return(madia); }
/// <summary> /// 通过给定的文件路径创建一个新的 VlcMedia /// </summary> /// <param name="vlc">Vlc 对象</param> /// <param name="path">文件路径</param> public static VlcMedia CreateFormPath(Vlc vlc, String path) { GCHandle handle = GCHandle.Alloc(Encoding.UTF8.GetBytes(path), GCHandleType.Pinned); var media = new VlcMedia(_createMediaFormPathFunction.Delegate(vlc.InstancePointer, handle.AddrOfPinnedObject())); handle.Free(); return(media); }
/// <summary> /// 使用已经设定好的路径,载入 LibVlc /// </summary> public static void LoadLibVlc() { if (!IsLibLoaded) { try { FileInfo libcore = new FileInfo(Path.Combine(LibDirectory, @"libvlccore.dll")); FileInfo libvlc = new FileInfo(Path.Combine(LibDirectory, @"libvlc.dll")); LibCoreHandle = Win32Api.LoadLibrary(libcore.FullName); LibHandle = Win32Api.LoadLibrary(libvlc.FullName); } catch (Win32Exception e) { throw new Exception("无法载入 LibVlc 库", e); } _getVersionFunction = new LibVlcFunction <GetVersion>(LibHandle); var versionString = InteropHelper.PtrToString(_getVersionFunction.Delegate()); var match = Regex.Match(versionString, "^[0-9.]*"); if (match.Success) { LibVersion = new Version(match.Groups[0].Value); } var devString = LibDev = versionString.Split(' ', '-')[1]; _newInstanceFunction = new LibVlcFunction <NewInstance>(LibHandle, LibVersion, devString); _releaseInstanceFunction = new LibVlcFunction <ReleaseInstance>(LibHandle, LibVersion, devString); _retainInstanceFunction = new LibVlcFunction <RetainInstance>(LibHandle, LibVersion, devString); _addInterfaceFunction = new LibVlcFunction <AddInterface>(LibHandle, LibVersion, devString); _setExitHandlerFunction = new LibVlcFunction <SetExitHandler>(LibHandle, LibVersion, devString); _waitFunction = new LibVlcFunction <Wait>(LibHandle, LibVersion, devString); _setUserAgentFunction = new LibVlcFunction <SetUserAgent>(LibHandle, LibVersion, devString); _setAppIdFunction = new LibVlcFunction <SetAppId>(LibHandle, LibVersion, devString); _getCompilerFunction = new LibVlcFunction <GetCompiler>(LibHandle, LibVersion, devString); _getChangesetFunction = new LibVlcFunction <GetChangeset>(LibHandle, LibVersion, devString); _freeFunction = new LibVlcFunction <Free>(LibHandle, LibVersion, devString); _releaseLibVlcModuleDescriptionFunction = new LibVlcFunction <ReleaseLibVlcModuleDescription>(LibHandle, LibVersion, devString); _getAudioFilterListFunction = new LibVlcFunction <GetAudioFilterList>(LibHandle, LibVersion, devString); _getVideoFilterListFunction = new LibVlcFunction <GetVideoFilterList>(LibHandle, LibVersion, devString); VlcError.LoadLibVlc(LibHandle, LibVersion, devString); VlcEventManager.LoadLibVlc(LibHandle, LibVersion, devString); VlcMedia.LoadLibVlc(LibHandle, LibVersion, devString); VlcMediaPlayer.LoadLibVlc(LibHandle, LibVersion, devString); IsLibLoaded = true; } }
/// <summary> /// Load LibVlc dlls, and mapping all function. /// </summary> /// <param name="libVlcDirectory">directory of LibVlc</param> /// <exception cref="LibVlcLoadLibraryException"> /// Can't load LibVlc dlls, check the platform and LibVlc target platform /// (should be same, x86 or x64). /// </exception> /// <exception cref="TypeLoadException">A custom attribute type cannot be loaded. </exception> /// <exception cref="NoLibVlcFunctionAttributeException"> /// For LibVlcFunction, need LibVlcFunctionAttribute to get Infomation /// of function. /// </exception> /// <exception cref="FunctionNotFoundException">Can't find function in dll.</exception> /// <exception cref="VersionStringParseException">Can't parse libvlc version string, it must like "2.2.0-xZune Weatherwax".</exception> /// <exception cref="OverflowException"> /// At least one component of version represents a number greater than /// <see cref="F:System.Int32.MaxValue" />. /// </exception> public static void LoadLibVlc(String libVlcDirectory = null) { LibVlcDirectory = libVlcDirectory == null ? "" : libVlcDirectory; if (IsLibLoaded) { return; } try { FileInfo libcore = new FileInfo(Path.Combine(LibVlcDirectory, "libvlccore.dll")); FileInfo libvlc = new FileInfo(Path.Combine(LibVlcDirectory, "libvlc.dll")); LibVlcVCoreHandle = Win32Api.LoadLibrary(libcore.FullName); LibVlcHandle = Win32Api.LoadLibrary(libvlc.FullName); } catch (Win32Exception e) { throw new LibVlcLoadLibraryException(e); } _getVersionFunction = new LibVlcFunction <GetVersion>(); LibVlcVersion = new LibVlcVersion(GetVersion()); _getCompilerFunction = new LibVlcFunction <GetCompiler>(); _getChangesetFunction = new LibVlcFunction <GetChangeset>(); _freeFunction = new LibVlcFunction <Free>(); _releaseLibVlcModuleDescriptionFunction = new LibVlcFunction <ReleaseLibVlcModuleDescription>(); _releaseAudioOutputListFunction = new LibVlcFunction <ReleaseAudioOutputList>(); _releaseAudioDeviceListFunction = new LibVlcFunction <ReleaseAudioDeviceList>(); _releaseTrackDescriptionFunction = new LibVlcFunction <ReleaseTrackDescription>(); _releaseTracksFunction = new LibVlcFunction <ReleaseTracks>(); Vlc.LoadLibVlc(); VlcError.LoadLibVlc(); VlcEventManager.LoadLibVlc(); VlcMedia.LoadLibVlc(); VlcMediaPlayer.LoadLibVlc(); AudioEqualizer.LoadLibVlc(); }
/// <summary> /// 通过给定的文件路径创建一个新的 VlcMedia /// </summary> /// <param name="path">文件路径</param> public VlcMedia CreateMediaFormPath(String path) { return(VlcMedia.CreateFormPath(this, path)); }
/// <summary> /// 通过给定的文件 Url 创建一个新的 VlcMedia,该 Url 的格式必须以 "file://" 开头,参见 "RFC3986". /// </summary> /// <param name="url">文件 Url</param> public VlcMedia CreateMediaFormLocation(String url) { return(VlcMedia.CreateFormLocation(this, url)); }
/// <summary> /// 通过给定的文件描述符创建一个新的 VlcMedia /// </summary> /// <param name="fileDescriptor">文件描述符</param> public VlcMedia CreateMediaFormFileDescriptor(int fileDescriptor) { return(VlcMedia.CreateFormFileDescriptor(this, fileDescriptor)); }
/// <summary> /// 通过名称创建一个新的 VlcMedia /// </summary> /// <param name="name">媒体名称</param> public VlcMedia CreateMediaAsNewNode(String name) { return(VlcMedia.CreateAsNewNode(this, name)); }
public static VlcMediaPlayer CreatFormMedia(VlcMedia media) { return new VlcMediaPlayer(_createMediaPlayerFromMediaFunction.Delegate(media.InstancePointer)); }
public MediaPlayerMediaChangedEventArgs(VlcMedia newMedia) { NewMedia = newMedia; }
public static VlcMediaPlayer CreatFormMedia(VlcMedia media) { return(new VlcMediaPlayer(CreateMediaPlayerFromMediaFunction.Delegate(media.InstancePointer))); }
private void PlayerOnMediaChanged( object sender, MediaPlayerMediaChangedEventArgs e ) { lastMedia = e.NewMedia; lastMedia.ParsedChanged += NewMediaOnParsedChanged; }