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
| Private Declare Function SetWindowLongA Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
'trouver le handle
Private Declare Function fwa Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
' Déclaration des fonctions API
Dim balvideo
Private Sub UserForm_Activate()
Handle = fwa(vbNullString, Me.Caption)
With WebBrowser1
.Silent = True
.Navigate "https://youtu.be/wYwAXFl26t0" 'on fait comme si on allait sur la page du clip
Do: DoEvents: Loop While .ReadyState <> 4 ' on attent que la page soit chargée
Me.Caption = Me.Caption & " lecture de : " & .Document.Title
Do: DoEvents: Set balvideo = .Document.getelementsbytagname("VIDEO"): Loop While balvideo.Length = 0
codehtml = "<meta http-equiv=""X-UA-Compatible"" content=""IE=edge,chrome=1,htaccess=1"">"
'on récupère le code HTML de l'embed(balise video html5)et on ajoute le auto play et les controls visibles
videohtml = Replace(.Document.getelementsbytagname("VIDEO")(0).outerhtml, "controlslist=""nodownload""", " controls preload autoplay allowfullscreen")
'maintenant on a le code de l'embed et rien que lui
.Document.body.innerhtml = codehtml & videohtml ' on le réinjecte dans le document de la page web en le récrivant
.Move 0,0, Me.InsideWidth - 100, Me.InsideHeight ' on cale le webbrowser a la dimention de l'interieur de l'userform
' on va agrandir a la dimention du document le lecteur maintenant
Set balvideo = .Document.getelementsbytagname("VIDEO")(0)
With balvideo
.Style.Left = 0: .Style.Top = 0: .Style.Width = "100%": .Style.Height = "100%" ' on cale aussi le player (balise video) a la dimention du document soit du userform aussi
Do: DoEvents: r = .Duration: Loop While r Like "*QN*" = True
TextBox1 = Val(.Duration) / 60
End With
End With
SetWindowLongA Handle, -16, &H94CF0080 ' on peut redimentionner l'userform avec la souris
' et voila enjoy yourself with your player html5 off youtube de la balle je te dis moi!!!
End Sub
Private Sub UserForm_Resize()
With WebBrowser1
.Left = 0: .Top = 0: .Width = Me.InsideWidth: .Height = Me.InsideHeight 0
Set doc = .Document
Set video = doc.getelementsbytagname("VIDEO")(0)
With doc.body.Style: .Width = "100%": .Height = "100%": End With
With video.Style: .Position = "absolute": .Width = "100%": .Height = "100%": .Left = 0: .zIndex = 0: .visibility = "visible": End With
End With
End Sub |