Jump to content

YouTube Player GUI


IAMK
 Share

Recommended Posts

I feel like some of this might not be possible, but I thought I'd ask.

I want to create a GUI which does the following:
1- Only has a full-screened YouTube video in it.
2- Is resizable, but contains the aspect ratio (The full-screen works with resizability).
3- Finds the aspect ratio of the video (if videos have different aspect ratios).
4- Videos autoplay.
5- A URL which displays the current playing video's link (for copy/share purposes).
6- A button which brings a popup GUI which does the following:
a- Allows searching the YouTube webpage for videos.
b- Clicking on a video will remove the GUI, and the video being watched on the main GUI will be the selected video.

Current status (problems in bold):
1- I need to manually press it. Choosing a new video would also break this.
2- Resizing works, but not to aspect ratio.
3- My plan is to read the source code for the aspect ratio (if there's no better way)?
4- Need to ensure autoplay is enabled. Don't know how to do this.
5- Implemented, but happens a million times. Way to improve this?
6- Trying to sort the others before I implement this, but this should be easy and replace the Search button.
a- Simple IE Browser...
b- My plan is to _IE_Navigate() the main GUI then hide the search GUI after finding the URL in the source of the video I clicked on? Is there a way to not go to the video in the search GUI, but rather just send the URL when a video is clicked?

#include <IE.au3>
#include <GUIConstantsEx.au3>

$MYGUI = GUICreate("YoutubePlayer", 440, 300, -1, -1, 0x00CF0000)
$URL = GUICtrlCreateCombo("http://youtube.com", 0, 0, 400)
GUICtrlSetResizing(-1, BitOr($GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKRIGHT, $GUI_DOCKHEIGHT))
$searchButton = GUICtrlCreateButton("Search", 400, 0, 40, 20)
GUICtrlSetResizing(-1, BitOr($GUI_DOCKTOP, $GUI_DOCKRIGHT, $GUI_DOCKSIZE))

$xy = WinGetClientSize($MYGUI)
$videoPlayer = _IECreateEmbedded()
GUICtrlCreateObj($videoPlayer, 0, 22, $xy[0], $xy[1] - 22)
GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
GUISetState()

_IENavigate($videoPlayer, GUICtrlRead($URL))

Do
   Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
         GUIDelete()
         Exit
      Case $searchButton
      _IENavigate($videoPlayer, GUICtrlRead($URL))
   EndSwitch

   GUICtrlSetData($URL, _IEPropertyGet($videoPlayer, "locationurl"))
   Sleep(100)
Until False

 

If anyone knows the solutions, it would be greatly appreciated.
Thanks.

Link to comment
Share on other sites

Hi @IAMK

For your #1, you could do a mix of getting the full screen button position on page (and getting page scroll pos) with js (there are many examples posted on this forum, showing different ways of getting control of the JS with AutoIt) and simply doing a mouse-click on your window at the position of the full screen button (maybe force it to show with js doing some mild CSS tweaking)

getting the fullscreen button could be done with:

document.querySelector('.ytp-fullscreen-button.ytp-button')

 

For your #4 there's a cookie named "PREF" you should look at

part of the value contains a key f5. if you open up browser developer tools and goto storage>cookies>https://youtube.com (I used Firefox for this) you can watch the value change ( i suggest doing it with maybe two different accounts, to verify that nothing changes. in my case the 4th char in the value changed from a 2 (on) to a 3 (off). So either it's a fixed position in the value, or a bitmask ^^

Hope this helps

Edited by genius257
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...