1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
Imports System.IO
' ---------ajouter references à ces dll situes dans le dossier FrankLibVLCWin----------
Imports Vlc.DotNet
Imports Vlc.DotNet.Core
Imports Vlc.DotNet.Core.Interops.Signatures
Imports Vlc.DotNet.Forms
' ---------ajouter references au projet ADDITIONNL CSHARP LibExtensions----------
Imports LibExtensions
Public Class Form1
'-------------IMPORTANT-----------
'L'APPLI NECESSITE LE CHEMIN DU DOSSIER D'INSTALLATION DE VIDEO LAN
' =>VLC DOIT ETRE INSTANLLE SUR LA MACHINE CLIENT
' dou le path en dur "C:\Program Files\VideoLAN\VLC"
' mais tu peux rajouter un FolderBrowseDialog
Public Sub New()
' Cet appel est requis par le concepteur.
InitializeComponent()
' Ajoutez une initialisation quelconque après l'appel InitializeComponent().
End Sub
Private Sub myVlcControl_VlcLibDirectoryNeeded(ByVal sender As System.Object, ByVal e As Vlc.DotNet.Forms.VlcLibDirectoryNeededEventArgs) Handles myVlcControl.VlcLibDirectoryNeeded
e.VlcLibDirectory = New DirectoryInfo("C:\Program Files\VideoLAN\VLC")
If e.VlcLibDirectory Is Nothing Then
Dim folderBrowserDialog As FolderBrowserDialog = New FolderBrowserDialog()
folderBrowserDialog.Description = "Select Vlc libraries folder."
folderBrowserDialog.RootFolder = Environment.SpecialFolder.Desktop
folderBrowserDialog.ShowNewFolderButton = True
If (folderBrowserDialog.ShowDialog() = DialogResult.OK) Then
e.VlcLibDirectory = New DirectoryInfo(folderBrowserDialog.SelectedPath)
End If
End If
End Sub
Private Sub ButtonPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonPlay.Click
myVlcControl.Play(
New Uri("http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_surround-fix.avi"))
'la cc'est les infos sur les chaloupes d'immigrants de Lampedusa !!!
myVlcControl.Play(
New Uri(Application.StartupPath + "\Videos\TV5MONDE EUROPEJan.mpg"))
End Sub
Private Sub ButtonStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonStop.Click
myVlcControl.Stop()
End Sub
Private Sub ButtonPause_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonPause.Click
myVlcControl.Pause()
End Sub
Private Sub myVlcControl_MediaChanged(ByVal sender As System.Object, ByVal e As Vlc.DotNet.Core.VlcMediaPlayerMediaChangedEventArgs) Handles myVlcControl.MediaChanged
'ControlExtensions.InvokeIfRequired(myLblMediaLength, l => l.Text = new DateTime(new TimeSpan((long)e.NewLength).Ticks).ToString("T"))
End Sub
Private Sub myVlcControl_PositionChanged(ByVal sender As System.Object, ByVal e As Vlc.DotNet.Core.VlcMediaPlayerPositionChangedEventArgs) Handles myVlcControl.PositionChanged
Dim position As Single = myVlcControl.GetCurrentMedia().Duration.Ticks * e.NewPosition
ControlExtensions.InvokeIfRequired(myLblVlcPosition, Sub(c)
c.Text = New DateTime(CType(position, Long)).ToString("T")
End Sub)
End Sub
Private Sub myVlcControl_Paused(ByVal sender As System.Object, ByVal e As Vlc.DotNet.Core.VlcMediaPlayerPausedEventArgs) Handles myVlcControl.Paused
ControlExtensions.InvokeIfRequired(myLblState, Sub(c)
c.Text = "Paused"
End Sub)
End Sub
Private Sub myVlcControl_Stopped(ByVal sender As System.Object, ByVal e As Vlc.DotNet.Core.VlcMediaPlayerStoppedEventArgs) Handles myVlcControl.Stopped
ControlExtensions.InvokeIfRequired(myLblState, Sub(c) c.Text = "Stopped")
ControlExtensions.InvokeIfRequired(
myCbxAspectRatio, Sub(c)
c.Text = String.Empty
c.Enabled = False
End Sub)
ControlExtensions.InvokeIfRequired(myLblAudioCodec, Sub(c) c.Text = "Codec: ")
ControlExtensions.InvokeIfRequired(myLblAudioChannels, Sub(c) c.Text = "Channels: ")
ControlExtensions.InvokeIfRequired(myLblAudioRate, Sub(c) c.Text = "Rate: ")
ControlExtensions.InvokeIfRequired(myLblVideoCodec, Sub(c) c.Text = "Codec: ")
ControlExtensions.InvokeIfRequired(myLblVideoHeight, Sub(c) c.Text = "Height: ")
ControlExtensions.InvokeIfRequired(myLblVideoWidth, Sub(c) c.Text = "Width: ")
End Sub
Private Sub myVlcControl_Playing(ByVal sender As System.Object, ByVal e As Vlc.DotNet.Core.VlcMediaPlayerPlayingEventArgs) Handles myVlcControl.Playing
ControlExtensions.InvokeIfRequired(myLblState, Sub(c) c.Text = "Playing")
ControlExtensions.InvokeIfRequired(myLblAudioCodec, Sub(c) c.Text = "Codec: ")
ControlExtensions.InvokeIfRequired(myLblAudioChannels, Sub(c) c.Text = "Channels: ")
ControlExtensions.InvokeIfRequired(myLblAudioRate, Sub(c) c.Text = "Rate: ")
ControlExtensions.InvokeIfRequired(myLblVideoCodec, Sub(c) c.Text = "Codec: ")
ControlExtensions.InvokeIfRequired(myLblVideoHeight, Sub(c) c.Text = "Height: ")
ControlExtensions.InvokeIfRequired(myLblVideoWidth, Sub(c) c.Text = "Width: ")
Dim mediaInformations() As MediaTrackInfosStructure = myVlcControl.GetCurrentMedia().TracksInformations
For Each mediaInformation As MediaTrackInfosStructure In mediaInformations
Dim item As MediaTrackInfosStructure = mediaInformation
If mediaInformation.Type = Core.Interops.Signatures.MediaTrackTypes.Audio Then
ControlExtensions.InvokeIfRequired(myLblAudioCodec, Sub(c) c.Text += item.CodecName)
ControlExtensions.InvokeIfRequired(myLblAudioChannels, Sub(c) c.Text += item.Audio.Channels.ToString)
ControlExtensions.InvokeIfRequired(myLblAudioRate, Sub(c) c.Text += item.Audio.Rate.ToString)
ElseIf (mediaInformation.Type = Core.Interops.Signatures.MediaTrackTypes.Video) Then
ControlExtensions.InvokeIfRequired(myLblVideoCodec, Sub(c) c.Text += item.CodecName)
ControlExtensions.InvokeIfRequired(myLblVideoHeight, Sub(c) c.Text += item.Video.Height.ToString)
ControlExtensions.InvokeIfRequired(myLblVideoWidth, Sub(c) c.Text += item.Video.Width.ToString)
End If
Next
ControlExtensions.InvokeIfRequired(
myCbxAspectRatio, Sub(c)
c.Text = myVlcControl.Video.AspectRatio
c.Enabled = True
End Sub)
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If myVlcControl.Video IsNot Nothing Then
myVlcControl.Video.AspectRatio = myCbxAspectRatio.Text
ResizeVlcControl()
End If
End Sub
Private Sub myVlcControl_SizeChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles myVlcControl.SizeChanged
ResizeVlcControl()
End Sub
Private Sub ResizeVlcControl()
If Not String.IsNullOrEmpty(myCbxAspectRatio.Text) Then
Dim ratio() As String = myCbxAspectRatio.Text.Split(":")
Dim width, height As Integer
If (ratio.Length = 2 And
Integer.TryParse(ratio(0), width) And
Integer.TryParse(ratio(0), height)) Then
myVlcControl.Width = myVlcControl.Height * width / height
End If
End If
End Sub
End Class |
Partager