Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Aaron's YouTube Television v2.2.2.7


  • Please log in to reply
136 replies to this topic
Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008
A lot of them are music videos. It'd be cool to see them there.

Have you come across any youtube advertisements with the embedded videos?
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

aaronbewza
  • Members
  • 466 posts
  • Last active: Feb 05 2013 08:40 AM
  • Joined: 20 Feb 2011
Yes there are ads but they only seem to show up in fullscreen mode. I used
(in my opinion) the best array of YouTube player "tags" in the embed code for each video
but there was not anything specific for ads:

version=3 (version 3 of the YouTube player)
border=0 (uhhh *scratches head*)
controls=1 (pause, play, progress etc are accessible)
modestbranding=1 (removes YouTube logo from video while it is playing)
autoplay=0 (does not play videos automatically, User must press play first)
autohide=1 (controls fade out after a second, until User moves mouse into screen)
showinfo=1 (video title and information is visible on the top of the screen)
rel=0 (does not show "Related Videos" menu after video is finished playing)
iv_load_policy=3 (does not show annotations)
showsearch=0 (does not show search menu)

sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010
Aaron, I would love to make some sample Youtube players based off this, since my previous attempts have failed. However, your script is so full of other things that I can't find the relevant function(s).

What is required to make only a Gui element that plays a video? I'm guessing you use COM to display the video? Can you demonstrate?

I agree that your settings are "best" btw. There can be some modifications depending on what you're gonna use it for, f.ex. autoplay=1 might be nice.

garry
  • Spam Officer
  • 3219 posts
  • Last active: Sep 20 2018 02:47 PM
  • Joined: 19 Apr 2005
@sumon, a small example with COM ( needs com.ahk, AHK_Basic )
MODIFIED=20101127
;--- example Youtube play
;--- needs com.ahk
;--- C:\Programme\AutoHotkey\Lib\com.ahk ---

;ytcd=_yv89dWJIHY
;ytcd=siJLeHAnZIk    ;fmt=22 chinese 1080HD Widescreen
ytcd=a502on4D_1k    ;Grace Chang Ge Lan


url=http://www.youtube.com/v/%ytcd%&autoplay=1

code =
(
<HTML><HEAD><TITLE></TITLE></HEAD><BODY topMargin=0 leftMargin=0 scroll=no>
<OBJECT width="100`%" height="100`%"><param name="movie" value="%url%"></param>
<param name="allowFullScreen" value="true" />
<EMBED width="100`%" height="100`%" src="%url%" type="application/x-shockwave-flash" allowfullscreen="true">
</EMBED></OBJECT></BODY></HTML>
)

COM_AtlAxWinInit()
Gui,2: +LastFound +Resize
gui,2: add, picture, HwndVideo x70 y10 w720 h480
pwb := COM_AtlAxCreateControl( Video, "Shell.Explorer")
;pwb := COM_AtlAxCreateControl( WinExist(), "Shell.Explorer")
COM_Invoke(pwb, "Navigate", "about:blank")
Gui,2:Add,Button,x5 y10  gTEST1,TEST
Gui,2:Show, w800 h500, Youtube - %url%
COM_Invoke(pwb, "document.write", code)
return

TEST1:
msgbox,Test
return

2GuiClose:
Gui,2: Destroy
COM_Release(pwb)
COM_AtlAxWinTerm()
ExitApp

2nd example Dansk Radio
;--- example play DANSKx RADIOx
;--- click høj for best audio quality
;--- needs com.ahk
;--- %A_programfiles%\AutoHotkey\Lib\com.ahk ---
;--- http://www.autohotkey.com/forum/topic34972.html
;----------------------------------------------------------------------------------------------
URL=http://www.dr.dk/drnetradio/index.dr?evt=k&name=evergreen

COM_AtlAxWinInit()
Gui,2: +LastFound +Resize
pwb := COM_AtlAxGetControl(COM_AtlAxCreateContainer(WinExist(),80,10,880,480, "Shell.Explorer") )
COM_Invoke(pwb, "Navigate",URL)
Gui,2:Add,Button,x5 y10  gRecord1,Record
Gui,2: Show, w900 h500, Dansk Radio - %url%
return

Record1:
no23=C:\Programme\No23 Recorder\no23 recorder.exe
ifexist,%no23%
  {
  Loop, %no23%
      run, %A_LoopFileShortPath%
  }
return


2GuiClose:
Com_Invoke(pwb, "silent", true)
COM_Release(pwb)
COM_AtlAxWinTerm()
Gui,2: Destroy
ExitApp

3rd example html xy.hta
Filename =Youtube_TEST2.hta
F1       =%A_scriptdir%\%filename%
;VR       =nKKBmnIfQxg
;VR       =iCKMzrPy4t4
VR       =AVDxCPffoPU
;VR       =QS6lDaKsBUs
TITLE    =%vr%

;filedelete,%f1%
ifnotexist,%f1%
{
  e4x=
  (Ltrim Join`r`n
<HTML>
<HEAD>
<TITLE>%title%</TITLE>
</HEAD>
<BODY>
<style type="text/css">
 body {
      background-color: #008080;
      margin:  0px;
      padding: 10px;
      color: #fff;
      overflow-y: hidden;
      overflow-x: hidden;
      }
</style>
<object width="870.400000" height="614.400000">
<param name="movie" value="http://www.youtube.com/v/%vr%&autoplay=1">
</param> <embed src="http://www.youtube.com/v/%vr%&autoplay=1" type="application/x-shockwave-flash" width="870.400000" height="614.400000">
 </embed> </object>
</BODY>
</HTML>
)
Fileappend,%e4x%`r`n,%f1%
}
run,%f1%
exitapp


nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
why COM.ahk?? SRSLY
COM_Invoke(pwb, "Navigate", "about:blank")
; vs
pwb.Navigate("about:blank")
I don't see why you prefer the former

garry
  • Spam Officer
  • 3219 posts
  • Last active: Sep 20 2018 02:47 PM
  • Joined: 19 Apr 2005
nimda, can you give an example , needs AHK_L ? ( didn't tried yet )

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
what are you asking?

sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010

what are you asking?


He wonders if you can give an example of how it can be written in AHK_L. Garry didn't try it in AHK_L yet.

I would also like that, if you (or someone) could make a SIMPLE example (the first one was good) that works with AHK_L, and uses the "nice" method of accessing COM. pwb.Navigate("about:blank") and so forth.

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
No I can't. I've never embedded anything before.

aaronbewza
  • Members
  • 466 posts
  • Last active: Feb 05 2013 08:40 AM
  • Joined: 20 Feb 2011
Sorry guys, I hooked up an air conditioner the other day and blew our circuit-breaker box (fusebox). There's no power for my computer until the electrician gets in. I'm whipping up something now here on wifey's computer... :) back shortly.

aaronbewza
  • Members
  • 466 posts
  • Last active: Feb 05 2013 08:40 AM
  • Joined: 20 Feb 2011
ok sumon I'm not sure if this is what you mean, but this one creates all the stuff you need for sizing the gui and the inner html container.
It's pretty easy, just enter the details it wants in the InputBoxes and BOOM!
I tried: pwb.Navigate("about:blank"), and pwb.document.write(code) which both work.
It accepts the share code from the "Share" button under any YouTube video at their site,
and StringReplace makes it possible to embed that video URL in the GUI.
; Aaron's version of YouTube Player

InputBox, w, Please Enter width, Please enter desired width of player`n(height will be calculated automatically)

h := w*9/16 ; Height equals width times 9/16 (for 16:9 screen ratio)

MsgBox width: %w% height: %h% ; Temporary

htmlwidth := w+4 ; Creates proper dimensions for the html container (the 4 extra pixels are because the HTML container is offset 2px every side to avoid a border)
htmlheight := h+4
guiwidth = %w% ; Gui will be the same width as video
guiheight := h+50 ; Gui hangs out the bottom under video, adjust this to whatever you need (right now it's 50px)

InputBox, url, YouTube Video Player, Copy/paste the YouTube Video's "Share" code here: ; URL for YouTube video, from the "Share" button at YouTube
  If ErrorLevel = 1
    ExitApp
IfNotInString, url, http://youtu.be/
  {
    MsgBox, The URL you entered does not seem to`nmatch the format which YouTube offers.`nPlease make sure the correct URL`nis copied and pasted here.
    ExitApp
  }
StringReplace, url, url, http://youtu.be/, http://www.youtube.com/v/, All ; Changes out "Share" URL with proper embed URL
url = %url%&version=3&border=0&controls=1&modestbranding=1&iv_load_policy=3&showsearch=0&autoplay=0&autohide=1&showinfo=1&rel=0 ; Adds YouTube tags after URL

ObjDetails = <object classid="clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95" type="application/x-oleobject" width="%w%" height="%h%" bufferingtime="5" scale="aspect">
RemainingParamNames =
  (
    <param name="width" value="455"><param name="height" value="323"><param name="bufferingtime" value="5"><param name="enableContextMenu" value="0">
    <param name="ShowDisplay" value="0"><param name="scale" value="aspect"><param name="showControls" value="0">
  )

HTMLbegin = ; The beginning of the displayed HTML document, all the way to the opening quotation mark for URL variable
  (
    <!DOCTYPE html><html><head><title>Television GUI</title><meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <style type="text/css">
    html { overflow: hidden; }
    body { background-color: #000000; margin: 0px 0px 0px 0px; }
    .fixed { position:fixed; }
    .over { position:fixed; z-order:2; }
    .under { z-order:-100; }
    </style></head><body>
  )
HTMLend = <param name="Filename" value="%url%">%RemainingParamNames%</object></body></html> ; The end of the displayed HTML document, starting from the closing quotation mark on URL variable

 ; ----------------------------------------------------------------------------------------->> 
 ; puts it all together into the "code" variable
code = %HTMLbegin%<object %id% %ObjDetails% src="%url%">%HTMLend%
 ; -----------------------------------------------------------------------------------------<<

COM_AtlAxWinInit()
  Gui, +LastFound +Resize
    pwb := COM_AtlAxGetControl(COM_AtlAxCreateContainer(hwnd:=WinExist()
  ,-2 ; left
  ,-2 ; top
  ,htmlwidth ; width of html container, calculated from width variable
  ,htmlheight ; height of html container, calculated from height variable
  ,"Shell.Explorer"))
  

Gui, Show, w%guiwidth% h%guiheight%, YouTube GUI ; Shows main window and title

pwb.Navigate("about:blank")
pwb.document.write(code)

;COM_Invoke(pwb, "Navigate", "about:blank") ; other method
;COM_Invoke(pwb, "document.write", code) ; other method

Return

GuiClose:
ExitApp



Should this be put up as a new script even though its based on others' findings?? It's not the YouTube Television at this point.

sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010
Thanks Aaron, that was exactly what I was asking for, good and simple example. However, it does not seem to worked (tried with several videos, using the correct youtu.be share-code). As usual, "standard" AHK, AHK_L x32 Unicode, Win 7 x64 and I have Win Media Player installed.

I only know the the OP .exe worked for me, nothing else did so far.

Oh, and yeah, I think it could be worth it as a new "script" or "how-to", it's probably gonna be helpful to more people than me. Atleast I would think it'd be.

PS. I feel sorry for you/your AC/your electricity.

aaronbewza
  • Members
  • 466 posts
  • Last active: Feb 05 2013 08:40 AM
  • Joined: 20 Feb 2011
LOL yah and I totally have a recording project to finish by a deadline as well. Thanks for the sympathy :)
Does the EXE work for you? If not, try having the com.ahk for ahk_L (this one, the unicode one by Sean)...
not sure why it requires this for script-only use, I just ran into that myself here on my wife's computer.
Could just the one specific function be taken out of com.ahk and used inside this script?

PS do you think that
pwb.Navigate("about:blank")
pwb.document.write(code)
versus:
COM_Invoke(pwb, "Navigate", "about:blank")
COM_Invoke(pwb, "document.write", code)

...may be part of the problem if com.ahk is not?

sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010
It might be the AtLaxWinInit, so in the long run the COM. I will try tomorrow!

garry
  • Spam Officer
  • 3219 posts
  • Last active: Sep 20 2018 02:47 PM
  • Joined: 19 Apr 2005
I use a netbook XP and ahk_basic
old com.ahk works for me ( see example above )
your first television.exe worked, but
now I can switch on but nothing happens when I select channel and
when close window , script disappears but script is running
( must close with Windows Task Manager )