Page 1 of 3

YouTube Player & Downloader

Posted: Fri Jul 28, 2017 1:36 pm
by JHPJHP

Re: YouTube Player

Posted: Fri Jul 28, 2017 2:02 pm
by RSBasic
Works fine, thank you. Image

Can you define all variables? (EnableExplicit)

Re: YouTube Player

Posted: Fri Jul 28, 2017 2:29 pm
by walbus
Very nice !

Re: YouTube Player

Posted: Fri Jul 28, 2017 3:18 pm
by davido
@JHPJHP,
Excellent.
Thank you, very much for sharing. :D

Re: YouTube Player

Posted: Fri Jul 28, 2017 5:17 pm
by kvitaliy
There is no error handler:
Current item is not in the list

Re: YouTube Player

Posted: Fri Jul 28, 2017 7:14 pm
by falsam
Thanks ^-^

Re: YouTube Player

Posted: Sat Jul 29, 2017 12:29 pm
by JHPJHP
Hi RSBasic, walbus, davido, kvitaliy, and falsam,

Thank you all for your comments...

RSBasic: If I started defining variables in this example, my OCD would force me to update everything I have ever posted. :mrgreen:

kvitaliy: Thank you for pointing out the error.

------------------------------------------------------

Updated:
- search window now returns multiple results
-- user-defined Structure field for Max Results, currently set to 10
-- hard-coded max of 50 results, overrides user-defined setting if greater then max
- search window settings are saved while the program is open
- some minor improvements when loading YouTube videos
- added additional error checking (thanks kvitaliy)

Re: YouTube Player

Posted: Sat Jul 29, 2017 3:24 pm
by kvitaliy
Thanks, good work!

Re: YouTube Player

Posted: Sun Jul 30, 2017 7:10 am
by JHPJHP
Hi kvitaliy,

You are most welcome.

I wanted to see how the example compiled, and noticed that there was still an external image...

Updated:
- compressed the external image, converted it to base64, than added it as an include file
- update also includes additional shortcut keys and a few small enhancements

NB*: Package now includes a compiled standalone executable.

--------------------------------------------------------------

Reposted the update...

Adding some Shortcut Keys without including a Constant affected typing into the search field.

Additional Shortcut Keys:
- Esc Key: exit Full Screen / close window
- Enter: submit search filter (field must have focus)
- Down Arrow + CTRL: scroll to first search result
- Left Arrow + CTRL: scroll to previous search result
- Right Arrow + CTRL: scroll to next search result
- Up Arrow + CTRL: scroll to last search result
- Spacebar + CTRL: submit current search result

Re: YouTube Player

Posted: Sun Jul 30, 2017 9:31 pm
by JHPJHP
Updated:
- updated Structures
- extended the search results
- improved the Search Filter
- optimized and cleaned up parts of the code

After scrolling to the last record, press the Next or Last button a second time, and a new request is made to the YouTube server for the next set of videos.
- if there are additional videos available, a plus [ + ] sign is displayed to the right of the count

After scrolling to the first record, press the Previous or First button a second time, and a new request is made to the YouTube server for the previously returned search results.
- if there are previously returned search results, a minus [ - ] sign is displayed to the left of the count

Re: YouTube Player

Posted: Mon Jul 31, 2017 8:01 am
by Fred
Works perfectly :)

Re: YouTube Player

Posted: Mon Jul 31, 2017 7:12 pm
by Kwai chang caine
Again a good works :wink:
Thanks to sharing 8)

Re: YouTube Player

Posted: Wed Aug 02, 2017 1:42 am
by JHPJHP
Hi Fred,

Thank you for taking the time to give it try. I cannot say enough how great PureBasic is; limitless :!:

Hi Kwai chang caine,

As always your support is appreciated; it stands out from the crowd.

-------------------------------------------------

Updated:
- included a small Playlist feature
- added some additional Shortcut Keys
- optimized various parts of the code

In order to keep the binary file a standalone executable, I have opted to save the Playlist items to an Alternate Data Stream.
- the Playlist can be demonstrated from the IDE, but the items will not survive a restart, unlike the compiled executable

Player Window:
- F1 Key: Toggle Shortcut Menu
- F2 Key: Open Search Window

- F10 Key: Redirect Video Request to YouTube Home Page
- F12 Key: Reload Default Video

- Esc Key: Exit Full Screen / Close Window

Search Window (search field has focus):
- Enter Key: Submit Search Filter
- Down Arrow + CTRL: Scroll to First Search Result
- Up Arrow + CTRL: Scroll to Last Search Result
- Left Arrow + CTRL: Scroll to Previous Search Result
- Right Arrow + CTRL: Scroll to Next Search Result
- Spacebar + CTRL: Submit Current Search Result

- Ins Key: Add Playlist Items (show playlist with first insert)
- Del Key: Delete PlayList Items (hide playlist after last delete)

Search Window (playlist has focus):
- Down Arrow: Scroll Down Playlist
- Up Arrow: Scroll Up Playlist
- Left Arrow + CTRL: Scroll to First Item
- Right Arrow + CTRL: Scroll to Last Item
- Spacebar + CTRL: Submit Selected Item

- Esc Key: Close Window

Re: YouTube Player

Posted: Thu Aug 03, 2017 5:17 am
by JHPJHP
Updated:
- modified the Playlist
- added a Loop option (default True), resulting in additional player controls

If the Playlist is hidden, the Submit button will load a video from the Search list.

If the Playlist is visible, the Submit button will load one or more videos, starting from the selected item down.
- a single video can be loaded by double-clicking the item, or using the Shortcut keys

A video can be loaded from the Search list using the Shortcut keys, even when the Playlist is visible, but the Search field must have focus.

NB*: See the previous post for a list of Shortcut keys.

-------------------------------------------------

Updated:
- added Drag and Drop
- [ F1 ] Information

After searching for videos, put your mouse cursor over the returned image. Initially you will Drag and Drop your selection onto the YouTube logo, enabling the Playlist.
- Drag and Drop any new items directly into the Playlist

NB*: Because the WebGadget does not support Drag and Drop, I came up with a simple workaround.

Re: YouTube Player

Posted: Fri Aug 04, 2017 12:46 am
by JHPJHP
Updated:
- added a Splash window
- added Command Parameters

1. Create a Shortcut from the executable.
2. From Properties / Shortcut / Target add the parameters.
3. Parameters use the following strict format: [parameter]=[value] [parameter]=[value] ...
-- Spaces are only allowed / required to seperate parameters.
-- Quotes are allowed, but not necessry.
-- Syntax is case insensitive.

Command Parameters
- VID || VideoID : set a start video when the player is opened; YouTube video ID
- M || Maximized : open the window maximzed (DEFAULT: 0 || 1)
- X : open the window at x location
- Y : open the window at y location
- W || Width : set the starting window width
- H || Height : set the starting window height
- MW || MinWidth : set the minimum window width
- MH || MinHeight : set the minimum window height
- FS || FullScreen : open the window in full screen (DEFAULT: 0 || 1)
- FSX || FullScreenX : open the window in full screen at x location
- FSY || FullScreenY : open the window in full screen at y location
- FSW || FullScreenWidth : set the full screen width
- FSH || FullScreenHeight : set the full screen height
- AS || AutoStart : attempt to start the video without user interaction (DEFAULT: 1 || 0)
- LV || LoopVideo : restart the video or playlist after it completes (DEFAULT: 1 || 0)
- SR || SaveResult : save search results (JSON file) to a subfolder in the same directory as the executable (DEFAULT: 0 || 1)
- MR || MaxResult : set the maximum number of search results (per page) that can be returned per request (DEFAULT: 10 || 1 - 50)
- OB || OrderBy : search parameter (DEFAULT: relevance || date | rating | title | videoCount | viewCount)
- RC || RegionCode : search parameter (DEFAULT: null || ISO 3166-1 alpha-2 Code)
- RL || RelevanceLanguage : search parameter (DEFAULT: en || ISO 639-1 Code)
- SS || SafeSearch : search parameter (DEFAULT: none || moderate | strict)
- VC || VideoCaption : search parameter (DEFAULT: none || any | closedCaption)
- VD || VideoDefinition : search parameter (DEFAULT: any || high | standard)
- VI || VideoDimension : search parameter (DEFAULT: 2d || 3d | any)
- VU || VideoDuration : search parameter (DEFAULT: any || long | medium | short)
- VE || VideoEmbeddable : search parameter (DEFAULT: any || true)
- VT || VideoType : search parameter (DEFAULT: any || episode | movie)
- APIK || APIkey : get a personal API key from here (required for searches); not sure how long the current key will be valid