Access and play YOUTUBE TV from VFP

Published on by Yousfi Benameur

Click on code to select [then copy] -click outside to deselect


this is the youtube application habitually used on smart TV .its very cool and dont show all garbages frequently set on yotube navigation.
the youtube TV was designed for the smart TV with remote control.Actually its extended to google app on navigators.
on the ie navigator (internetexplorer.application here) can navigate to the app without the security problems encountered and it works as well with the schema i designed (launch by a top level invisible form and closed after starting IEapp).
otherwise if you build an exe it always stays in taskManager (refrences always not released).

with an IE olecontrol (shell.explorer.2) embed on a form  youtubeTV dont work at all and its blocked).

here can navigate with mouse and the 4 arrows key (left-right-up,down)
press ESC to return ans S to search for any video on Youtube (embed keyboard in app for TV .can type string to search in PC or type with the keyboard).
Press G for guide.
can connect in custom google youtube compte in menu app.
note on Smart TV you use the remote control to navigate.On your PC the mouse and some arrows are used as well or typing with the embed keyboard.

the builexe.prg (code 2) builds for you programmatly the youtube_new.exe.can make a shorcut on desktop to play ,or pin it in taskbar....

One notable advantage i found in youtubeTV on PC is to type unicode string to search (or paste unicode clipboard).

Of course internet must be connected !
[Post236]


Click on code to select [then copy] -click outside to deselect



*1*
*created on 13 of september 2017
*save this code mandatory as youtube_new0.prg (for building an exe lately)
*this is the main prg file

If !_vfp.StartMode=0
	On Shutdown Quit
Endi

_Screen.WindowState=1
Publi yform
yform=Newobject("youtubeTV")
yform.Show
Read Events
Retu
*
Define Class youtubeTV As Form
	BorderStyle = 3
	Top = 38
	Left = 0
	Height = 53
	Width = 126
	ShowWindow = 2
	ShowInTaskbar = .F.
	DoCreate = .T.
	Caption = ""
	MaxButton = .F.
	AlwaysOnTop = .T.
	Name = "Form1"


	Add Object timer1 As Timer With ;
		Top = 12, ;
		Left = 72, ;
		Height = 23, ;
		Width = 23, ;
		Interval = 5000, ;
		Name = "Timer1"


	Procedure Init
		*Created on Friday 12 of september 2017

		Publi  apie
		apie=Newobject("internetexplorer.application")
		With apie
			.Navigate("https://www.youtube.com/tv#/browse-sets?c=default&resume")    &&for search interface only can navigate to :https://www.youtube.com/tv#/search?resume
			.Toolbar=0
			.menubar=0
			.StatusBar=0
			.Width=Sysmetric(1)
			.Height=Sysmetric(2)
			.Resizable=1
			.Visible=.F.
		Endwith

		This.WindowState=1
		This.Visible=.F.
	Endproc


	Procedure Destroy
		**changing ie icon
		*Constants for SendMessage second parameter
		#Define WM_GETICON 0x7F
		#Define WM_SETICON 0x80

		*Constants for SendMessage third parameter
		#Define ICON_SMALL 0
		#Define ICON_BIG 1
		lnHWND=apie.HWnd
		*messagebox(trans(lnHWND),0+32+4096,'',500)
		lnIcon = ExtractIcon (0,Home(1)+"GRAPHICS\ICONS\misc\camera.ICO",0)
		SendMessage(lnHWND, WM_SETICON, ICON_SMALL, lnIcon)


		*changng IE caption
		With apie
			.Visible=.T.
			SetWindowText(.HWnd, "New Youtube App for smart TV- added on 12 of september 2017.")
			BringWindowToTop(.HWnd)
      declare integer ShowWindow  in  user32 integer,integer
*update for maximize window      
#DEFINE SW_SHOWMAXIMIZED 3
ShowWindow(.hwnd,SW_SHOWMAXIMIZED)     && maximize apie window to full screen (with titlebar)
		Endwith


		apie=Null
		Release apie

		Local m.myvar
		TEXT to m.myvar pretext 7 noshow
this is the youtube application for TV .its very attractive.
the youtube TV was designed for the smart TV on the market actually.
the ie navigator (internetexplorer.application here) can navigate to the app without the security problems encountered on a vfp form.
and it works as well with the schema i designed (launch by a top level invisible form and closed).
otherwise if you build an exe it always stays in taskManager (refrences not released).

with an IE olecontrol embed on a form (here  youtubeTV dont work at all and blocked).
the interface presents recent video (or searched by the user) as thumbs with a menu...
here can navigate with mouse and the 4 arrows key (left-right-up,down)
press ESC to return ans S to search for any video on Youtube (embed keyborad in app).
Press G for guide.
can connect in custom youtube compte in menu app.
note on Smart TV you use the remote control to navigate.On your PC the mouse and some arrows are used as well.

the ybuilexe.prg (code 2) builds the youtube_new.exe

Note: a simple code as prg can be built but the problem in exe file stays in taskmanager.to avoid this important
*problem, i created a form (not shown on taskbar and invisible to launch the App and release (with main  public variable as apie)
		ENDTEXT
		*messagebox(m.myvar,0+32+4096,"",6000)
		Local oshell
		oshell = Createobject('WScript.Shell')
		oshell.Popup(m.myvar,0, 'Summary help', 0+32+4096)  &&4,16,48,64...
		oshell=Null
		Clea Events
	Endproc


	Procedure Load
		Declare Integer Sleep In kernel32 Integer
		Declare Integer BringWindowToTop    In user32 Integer
		Declare Integer SetWindowText In user32;
			INTEGER HWnd, String lpString
		Declare Integer ExtractIcon In shell32 Integer hInst, String  lpszExeFileName, Integer lpiIcon
		Declare Integer SendMessage In user32 Integer HWnd, Integer Msg, Integer wParam, Integer Lparam
	Endproc


	Procedure timer1.Timer

		Try
			If !apie.Width=0        &&vartype (apie)="O" and ! isnull(apie)
				Thisform.Release
			Endi
		Catch
			Thisform.Release
		Endtry
	Endproc


Enddefine
*
*-- EndDefine:YoutbeTV



Click on code to select [then copy] -click outside to deselect


*2*created on wednesday 13 of september 2017
*save this prg as ybuildexe.prg
*it builds an executable app and cleans all tools used to achieve this goal.
*the executable built is youtube_new.exe (can create a desktop shortcut to run it or pin it on taskbar....)

set safe off
local m.yrep
m.yrep=addbs(justpath(sys(16,1)))
set defa to (yrep)

*build file configuration config.fpw
Local m.myvar
TEXT to m.myvar noshow
screen=off
resource=off
safe=off
ENDTEXT
Strtofile(m.myvar, "config.fpw")


*build proj and compile to exe
Build Project yfoo  From  "youtube_new0.prg" ,"config.fpw"
Build Exe youtube_new.Exe From yfoo
Inkey(1)

*clean traces
Dele File yfoo*.*
If File("youtube_new.exe")
    Messagebox("youtube_new.exe created!",0+32+4096,"Create an exe",1000)
Endi

try
Dele File config.fpw
catch
endtry

Set Safe On

run/n youtube_new.exe


Access and play YOUTUBE TV from VFP
Access and play YOUTUBE TV from VFP
Access and play YOUTUBE TV from VFP
Access and play YOUTUBE TV from VFP
Access and play YOUTUBE TV from VFP

Important:All Codes above are tested on VFP9 SP2 & windows 10 and internet explorer11

Comment on this post

Azarl 09/14/2017 09:46

Thank you - excellent work. Please keep it going