PLAY youtube in a GUI

Post your working scripts, libraries and tools
garry
Posts: 2400
Joined: 22 Dec 2013, 12:50

PLAY youtube in a GUI

10 Apr 2020, 09:10

the quality with videolan was better but I had no more success with vlc.exe to play youtube
you can watch videos from ahk-users interviewed from Joe Glines or with button RUN open URL
video Interview with Joe Glines / WEBINAR https://www.autohotkey.com/boards/viewtopic.php?f=17&t=54206
maybe can only play videos where embed is allowed

Code: Select all

;-MODIFIED = 20200410
;-CREATED  = 20200401
;- file    = PLAY YOUTUBE in a GUI
;
;- video Interview with Joe Glines  / WEBINAR https://www.autohotkey.com/boards/viewtopic.php?f=17&t=54206
;- links below button YT_AHK
;----------------------------------------------------------------------------------------------
#warn
#noenv
setworkingdir,%a_scriptdir%
filename1=YOUTUBE_TEST

wa:=A_screenwidth
ha:=A_screenHeight
xx:=101
Gui,3: -DPIScale
Gui,3:Color,Black,Black
Gui,3:Font,s13 cGray,Lucida Console
Gui,3:default

cx:=""
ck:=""

gosub,examples          ; <<<<<<<<<<<<
;--------------------
sect2=
(Ltrim Join`r`n
YT_AHK ;%yt_ahk%
Youtube;%yt1%
)

loop,parse,sect2,`n,`r
  {
  x:=a_loopfield
  if x=
     break
  stringsplit,k,x,`;
  cx .= k1 . "|"
  ck .= k2 . "|"
  }

stringsplit,m,ck,`|
stringsplit,h,cx,`|
totx:=(h0-1)

x :=(wa*.3)/xx,y :=(ha*.1)/xx,w :=(wa* 4)/xx,hx:=(ha*2.0)/xx,v :=(ha*0.25)/xx
Gui,3:add,text,section x%x% y%y% w0 h0,
I=0
Loop,%totx%
  {
  i++
  ;i:=SubStr(0 i, -1)                         ;- i 01-09
  BTName:= h%i%
  ;Gui,3: Add, Button, x+%v%  ys  w%w%  h%hx% gStart v%btname% ,%btname%   ;- horizontal
  Gui,3: Add, Button, xs  y+%v%  w%w%  h%hx% gStart v%btname% ,%btname%    ;- vertikal

  }

xxb=Shell.Explorer     ;- IExplorer
;xxb=Mozilla.Browser    ;- Mozilla Firefox

Fix := True
if Fix
    Prev := FixIE()
;------------------     ACTIVE-X
;x:=(wa*30)/xx ,y:=(ha*30)/xx,w:=(wa*40)/xx,h:=(ha*30)/xx  ;- small
x:=(wa*8)/xx ,y:=(ha*1)/xx,w:=(wa*90)/xx,h:=(ha*88)/xx  ;- big
Gui,3:Add,ActiveX, x%x% y%y% w%w% h%h% vWB,%xxb%
;------------------
WB.Silent := True

x:=(wa*1)/xx ,y:=(ha*92)/xx,w:=(wa*20)/xx,h:=(ha*2)/xx
Gui,3:Add,Edit,x%x% y%y% w%w% h%h% vTitle,


x:=(wa*22)/xx ,y:=(ha*92)/xx,w:=(wa*6)/xx,h:=(ha*2)/xx
Gui,3:Add,Edit,x%x% y%y% w%w% h%h% vURL2,


x:=(wa*29)/xx ,y:=(ha*92)/xx,w:=(wa*4)/xx,h:=(ha*2)/xx
Gui,3:Add,Button,x%x% y%y% w%w% h%h% vRUN gRUN,<RUN


w:=(wa*99.9)/xx,h:=(ha*97)/xx
Gui,3:Show,x0 y0 w%w% h%h%,%filename1%
GuiControl,3:Disable,RUN
return
;----------------
3Guiescape:
3Guiclose:
WB.Document.close
WB := ""
exitapp
esc::exitapp
;----------------

run:
Gui,3:submit,nohide
xxa=https://www.youtube.com/watch?v=%url%&autoplay=1&auto_play=true
try
 run,%xxa%
return


;---------------------------------------------------------
;- from user geekdude 20120107
FixIE(Version=0, ExeName="")
{
	static Key := "Software\Microsoft\Internet Explorer"
	. "\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION"
	, Versions := {7:7000, 8:8888, 9:9999, 10:10001, 11:11001}
	
	if Versions.HasKey(Version)
		Version := Versions[Version]
	
	if !ExeName
	{
		if A_IsCompiled
			ExeName := A_ScriptName
		else
			SplitPath, A_AhkPath, ExeName
	}
	
	RegRead, PreviousValue, HKCU, %Key%, %ExeName%
	if (Version = "")
		RegDelete, HKCU, %Key%, %ExeName%
	else
		RegWrite, REG_DWORD, HKCU, %Key%, %ExeName%, %Version%
	return PreviousValue
}
;----------------------------------------------------
start:
gui,3:submit,nohide
m:=""
mtview321:=""
Mousegetpos,,,,Ctrl       ;- Button1
r:= a_guicontrol          ;- vVar ( Buttonname )
stringtrimleft,ct,ctrl,6  ;- Button-(1)
url:=  m%ct%
;------------
;msgbox,R=%r%`nCTRL=%ctrl%`nct=%ct%`nURL=%url%
;------------
GuiControl,3:Disable,RUN
goto,menux 
return
;------------
;======================================================
menux:
empty=
  Menu, CMenu, add, %empty%,menudo
Menu,cmenu,deleteall
;msgbox, 262208,TEST-MENU,R=%r%`nCTRL=%ctrl%`nct=%ct%`nURL=%url%
   Loop, parse,url, `£, 
      {
	  cx1=
	  cx2=
      stringsplit,cx,a_loopfield,`$
      Menu, CMenu, add, %cx1%,menudo
      bt%a_index%:=cx2
      text%a_index%:=cx1
	  }
  MouseGetPos, musX, musY
  Menu, CMenu, Show, %musX%,%musY%
  return
;--------------
menuDo:
Gui,3:default
y:=A_ThisMenuItemPos
URL  :=bt%y%
text1:=text%y%
;msgbox, 262208,TEST-MENU-DO,R=%r%`nCTRL=%ctrl%`nct=%ct%`nURL=%url%`nText1=%text1%
;return

stringmid,textx1,text1,1,1
if (textx1="#")
 {
 run,%url%
 return
 }

if (r="YOUTUBE" or r="YT_AHK")
   {
   urlx=https://www.youtube.com/embed/%url%?autoplay=1
   WB.Navigate(URLx)
   if Fix
     FixIE(Prev)
   GuiControl,3:, Title,%text1%
   GuiControl,3:, URL2 ,%url%
   GuiControl,3:Enable,RUN
   return
   }
return
;-------------------------------

examples:
;-- interview with Joe Glines > https://www.autohotkey.com/boards/viewtopic.php?f=17&t=54206
YT_AHK=
(Ltrim join£ `%
#Joe-Glines_AHK-Users-Interviews           $https://www.autohotkey.com/boards/viewtopic.php?f=17&t=54206
Jean-Lalonde_JnLlnd                        $p00RJKF8zy0
#Jean-Lalonde_JnLlnd/Quick Access Popup    $https://www.quickaccesspopup.com/
Chad-Wilson_Maestrith                      $vSOtyc9Xs00  
#Chad-Wilson_Maestrith/AutoHotkey Studio   $http://www.maestrith.com
Jack-Dunning                               $rGsB550bPfw
#Jack-Dunning/Blog                         $https://jacksautohotkeyblog.wordpress.com/author/jackdunning/
Charlie-Simmons_Tank                       $EEgrf-jPTTI
Nicolás-Castillo_nicocs29                  $tFc7D-BJP98
Mitch-Berry_Mitchilich                     $LrC1f2sYJcQ
Jim-Ford_JFord                             $yz5XwxO1PmU
Susan-Thomas                               $4vrDDmxRzgU
Joe-Glines                                 $rlloxmN-3Ek 
#Joe-Glines/The-Automator                  $https://the-automator.com/
Isaias-Baez_RaptorX                        $7nav5-snPcA
#Isaias-Baez_RaptorX/YouTube               $https://www.youtube.com/user/ahkTuts
Dr.Gabriel-Cook_sillyscriptz               $39nGuW8ZnM4
Ryan-Wells_r2997790                        $Lixx0vCZ1mc
Hellbent                                   $o2npgeDI5vU
#Hellbent/YouTube                          $https://www.youtube.com/channel/UCge0TKjySLXd8xeLib8F0rA
joedf                                      $E0M6YPERhNY
Steve-Maziarz                              $iNZlhylDFpw
Jackie-Sztuk_BlackholyMan                  $57n_ajWoT78 
#Jackie-Sztuk_BlackholyMan/JszApp.com      $https://jszapp.com
Rick-C                                     $uFKqEsRgLi4
Jesús-Prieto                               $e5AGM8GNDV4 
#Jesús-Prieto/Blog                         $https://www.gonduana.com/blog
James-Griffing                             $Ahds43c6x1o
Michael-Wilson                             $Ixs8bpsq84s
#Michael-Wilson/Github                     $https://github.com/humanfactors
Joe-Winograd                               $ZvhtM7LfbmQ 
#Joe-Winograd/ExpertsExchange              $https://www.linkedin.com/in/joewinograd
Jethrow                                    $8P9Wo3fjcIY
#Jethrow/Jethrow                           $https://www.autohotkey.com/boards/memberlist.php?mode=viewprofile&u=112
Gio-Sperotto_Gio                           $8ekQfHU8JeI
Sebastian_SL5                              $LCVe4l1Cs2o
Ernestas-Ceciorka                          $mY5H8xSx9hw
Mason-George_Masonjar13                    $cmnk7SLLL5k
)


;-- for YOUTUBE link examples
yt1=
(Ltrim join£ % `
cn_呂珊-舞伴淚影 (姚莉玫瑰傳奇演唱會)$zPUBeRu01kA
cn_姚莉-春風吻上我的臉$FpWTUSMwgJA
cn_呂珊-春風吻上我的臉 (姚莉玫瑰傳奇演唱會)$elbjPNd0-Kk
en_Beautiful dreamer-Mandy Barnett$NpR9gl3-gic
en_Paris in the rain-Maria Friedman$C12giNk-4OQ
nl_Lubach_Kernenergie$YjFWiMJdotM
ru_Слуга народа$GZ-3YwVQV0M
br_De papo pro ar-Deborah Rosa$CnFlYCFLLbA
br_Assim como o rio-Leila Silva$_QpHwLddlTg
cn_晚霞_Sunset_韵儿_演唱 :韵儿[Yoonie]$2qH67_iUx-s
cn_Calypso dong-Ge Lan$ZIfpCLrjXVU
jp_Bengawan Solo_Toshi Matsuda$QZubtfzP_es
kh_Bengawan Solo-បឹងហ្គាវ៉ាន់សូឡូ - Cambodia$NEE4Ls8SMSs
es_El Relicario-Lilian de Celis$sraZaL6jylM
es_Aragon_Navarra-Rocio Durcal$NCNTujvB4Eg
es_Que la Mar Es Muy Traidora-Lilian de Celis$RTSRpZVDbFQ
pt_Aquela janela virada pro mar$iCKMzrPy4t4
#PT_Miguel_Catarino_YT$https://www.youtube.com/channel/UCLcXSPiATFcJU0ddNywFmFw/videos
#VoxDoku$https://www.youtube.com/user/voxdotcom/videos
#NL_ARCHIVE$https://www.youtube.com/user/BeeldenGeluid/videos
#UK_PATHE$https://www.youtube.com/user/britishpathe/videos
#US_OLDIES$https://www.youtube.com/channel/UCDG3-niIfxCzj7BWd2hgQLQ/videos
#US_OLDIES_50-60$https://www.youtube.com/channel/UCjSPBCGqUwQBAPjGB6LpK3w
#RU_MASHA$https://www.youtube.com/user/MashaBearEN/videos
#NL_Lubach$https://www.youtube.com/channel/UCdH_8mNJ9vzpHwMNwlz88Zw/videos
#Jim_Reeves$https://www.youtube.com/results?search_query=jim+reeves&search_type=
#Archive_Films$https://archive.org/details/Comedy_Films
#The_White_House$https://www.youtube.com/channel/UCYxRlFDqcWM4y7FfpiAN3KQ
)
return

;======================= END script YOUTUBE PLAY =========================================

Return to “Scripts and Functions”

Who is online

Users browsing this forum: mabohango and 15 guests