Code : Tout sélectionner
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
_IEErrorHandlerRegister()
$embedCode = '<html><head><body><div style="position: absolute; top:0px; left:0px; align: center"><iframe width="400" height="300" src="http://www.youtube.com/embed/{videoID}" frameborder="0" allowfullscreen></iframe></div></body></head></html>'
$oIE = _IECreateEmbedded()
$gui = GUICreate("Youtube watcher", 440, 440)
$url = GUICtrlCreateInput("http://www.youtube.com/watch?v=7rvNmVuGf84", 10, 10, 390, 20)
$go = GUICtrlCreateButton("->", 410, 10, 20, 20)
$ieID = GUICtrlCreateObj($oIE, 20, 40, 400, 300)
$play = GUICtrlCreateButton(">> | ||", 10, 380, 120, 20)
GUICtrlSetTip(-1, "Play / Pause")
$restart = GUICtrlCreateButton("[<-", 140, 380, 50, 20)
GUICtrlSetTip(-1, "Jump to the beginning of a video")
$back5sec = GUICtrlCreateButton("<- 5s", 200, 380, 50, 20)
GUICtrlSetTip(-1, "Seek back 5 seconds")
$forward5sec = GUICtrlCreateButton("5s ->", 270, 380, 50, 20)
GUICtrlSetTip(-1, "Seek forward 5 seconds")
$mute = GUICtrlCreateButton("M", 10, 410, 50, 20)
GUICtrlSetTip(-1, "Mute")
$fullScreen = GUICtrlCreateButton("[ <-> ]", 70, 410, 50, 20)
GUICtrlSetTip(-1, "Fullscreen view (Press ESC to leave fullscreen mode)")
Local $commands[6][2] = [ [ $play, "{SPACE}" ] , _
[ $restart, "0" ] , _
[ $back5sec, "{LEFT}" ] , _
[ $forward5sec, "{RIGHT}" ] , _
[ $mute, "M" ] , _
[ $fullScreen, "F" ] ]
GUISetState()
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then Exit
If $msg = $go Then
$videoID = GUICtrlRead($url)
If StringRegExp($videoID, "\Ahttp://.*v=") Then $videoID = StringRegExpReplace($videoID, ".*v=(.*)", "$1")
$f = FileOpen(@TempDir & "\youtubeEmbeded.html", 2)
FileWrite($f, StringReplace($embedCode, "{videoID}", $videoID) )
FileClose($f)
_IENavigate ($oIE, "file://" & @TempDir & "\youtubeEmbeded.html")
$oIE.document.body.scroll = "no"
EndIf
For $i = 0 To UBound($commands, 1) - 1
If $msg = $commands[$i][0] Then
ControlFocus($gui, "", "[CLASS:MacromediaFlashPlayerActiveX; INSTANCE:1]")
ControlSend($gui, "", "[CLASS:MacromediaFlashPlayerActiveX; INSTANCE:1]", $commands[$i][1] )
EndIf
Next
WEnd