1'' Copyright (c) MediaArea.net SARL. All Rights Reserved. 2 '' 3 '' Use of this source code is governed by a BSD-style license that can 4 '' be found in the License.html file in the root of the source tree. 5 '' 6 7''+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 8'' 9'' Microsoft Visual Basic wrapper for MediaInfo Library 10'' See MediaInfo.h for help 11'' 12'' To make it working, you must put MediaInfo.Dll 13'' in the executable folder 14'' 15''+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 16 17Imports System.Runtime.InteropServices 18 19Public Enum StreamKind As UInteger 20 General 21 Video 22 Visual = Video 'Deprecated 23 Audio 24 Text 25 Other 26 Image 27 Menu 28 Max 29End Enum 30 31Public Enum InfoKind As UInteger 32 Name 33 Text 34 Measure 35 Options 36 NameText 37 MeasureText 38 Info 39 HowTo 40 Max 41End Enum 42 43Public Enum InfoOptions As UInteger 44 ShowInInform 45 Reserved 46 ShowInSupported 47 TypeOfValue 48 Max 49End Enum 50 51Public Class MediaInfo 52 Private Declare Unicode Function MediaInfo_New Lib "MediaInfo.DLL" () As IntPtr 53 Private Declare Unicode Sub MediaInfo_Delete Lib "MediaInfo.DLL" (ByVal Handle As IntPtr) 54 Private Declare Unicode Function MediaInfo_Open Lib "MediaInfo.DLL" (ByVal Handle As IntPtr, ByVal FileName As String) As UIntPtr 55 Private Declare Unicode Sub MediaInfo_Close Lib "MediaInfo.DLL" (ByVal Handle As IntPtr) 56 Private Declare Unicode Function MediaInfo_Inform Lib "MediaInfo.DLL" (ByVal Handle As IntPtr, ByVal Reserved As UIntPtr) As IntPtr 57 Private Declare Unicode Function MediaInfo_GetI Lib "MediaInfo.DLL" (ByVal Handle As IntPtr, ByVal StreamKind As UIntPtr, ByVal StreamNumber As UIntPtr, ByVal Parameter As UIntPtr, ByVal KindOfInfo As UIntPtr) As IntPtr 'See MediaInfoDLL.h for enumeration values 58 Private Declare Unicode Function MediaInfo_Get Lib "MediaInfo.DLL" (ByVal Handle As IntPtr, ByVal StreamKind As UIntPtr, ByVal StreamNumber As UIntPtr, ByVal Parameter As String, ByVal KindOfInfo As UIntPtr, ByVal KindOfSearch As UIntPtr) As IntPtr 59 Private Declare Unicode Function MediaInfo_Option Lib "MediaInfo.DLL" (ByVal Handle As IntPtr, ByVal Option_ As String, ByVal Value As String) As IntPtr 60 Private Declare Unicode Function MediaInfo_State_Get Lib "MediaInfo.DLL" (ByVal Handle As IntPtr) As UIntPtr 'see MediaInfo.h for details 61 Private Declare Unicode Function MediaInfo_Count_Get Lib "MediaInfo.DLL" (ByVal Handle As IntPtr, ByVal StreamKind As UIntPtr, ByVal StreamNumber As IntPtr) As UIntPtr 'see MediaInfoDLL.h for enumeration values 62 63 Dim Handle As IntPtr 64 65 Sub New() 66 Handle = MediaInfo_New() 67 End Sub 68 Protected Overrides Sub Finalize() 69 MediaInfo_Delete(Handle) 70 End Sub 71 Function Open(ByVal FileName As String) As System.UIntPtr 72 Return MediaInfo_Open(Handle, FileName) 73 End Function 74 Sub Close() 75 MediaInfo_Close(Handle) 76 End Sub 77 Function Inform() As String 78 Return Marshal.PtrToStringUni(MediaInfo_Inform(Handle, CType(0, UIntPtr))) 79 End Function 80 Function Get_(ByVal StreamKind As StreamKind, ByVal StreamNumber As Integer, ByVal Parameter As Integer, Optional ByVal KindOfInfo As InfoKind = InfoKind.Text) As String 81 Return Marshal.PtrToStringUni(MediaInfo_GetI(Handle, CType(StreamKind, UIntPtr), CType(StreamNumber, UIntPtr), CType(Parameter, UIntPtr), CType(KindOfInfo, UIntPtr))) 82 End Function 83 Function Get_(ByVal StreamKind As StreamKind, ByVal StreamNumber As Integer, ByVal Parameter As String, Optional ByVal KindOfInfo As InfoKind = InfoKind.Text, Optional ByVal KindOfSearch As InfoKind = InfoKind.Name) As String 84 Return Marshal.PtrToStringUni(MediaInfo_Get(Handle, CType(StreamKind, UIntPtr), CType(StreamNumber, UIntPtr), Parameter, CType(KindOfInfo, UIntPtr), CType(KindOfSearch, UIntPtr))) 85 End Function 86 Function Option_(ByVal Option__ As String, Optional ByVal Value As String = "") As String 87 Return Marshal.PtrToStringUni(MediaInfo_Option(Handle, Option__, Value)) 88 End Function 89 Function State_Get() As Integer 90 Return CInt(MediaInfo_State_Get(Handle)) 91 End Function 92 Function Count_Get(ByVal StreamKind As StreamKind, Optional ByVal StreamNumber As UInteger = UInteger.MaxValue) As Integer 93 If StreamNumber = UInteger.MaxValue Then 94 Return CInt(MediaInfo_Count_Get(Handle, CType(StreamKind, UIntPtr), CType(-1, IntPtr))) 95 Else 96 Return CInt(MediaInfo_Count_Get(Handle, CType(StreamKind, UIntPtr), CType(StreamNumber, IntPtr))) 97 End If 98 End Function 99End Class 100