YouTube Player & Downloader

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: YouTube Player

Post by RSBasic »

Works fine, thank you. Image

Can you define all variables? (EnableExplicit)
Image
Image
walbus
Addict
Addict
Posts: 929
Joined: Sat Mar 02, 2013 9:17 am

Re: YouTube Player

Post by walbus »

Very nice !
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: YouTube Player

Post by davido »

@JHPJHP,
Excellent.
Thank you, very much for sharing. :D
DE AA EB
kvitaliy
Enthusiast
Enthusiast
Posts: 162
Joined: Mon May 10, 2010 4:02 pm

Re: YouTube Player

Post by kvitaliy »

There is no error handler:
Current item is not in the list
Last edited by kvitaliy on Thu Aug 03, 2017 10:43 am, edited 1 time in total.
User avatar
falsam
Enthusiast
Enthusiast
Posts: 630
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: YouTube Player

Post by falsam »

Thanks ^-^

➽ Windows 11 64-bit - PB 6.0 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: YouTube Player

Post 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)
Last edited by JHPJHP on Mon Jul 31, 2017 4:46 am, edited 4 times in total.
kvitaliy
Enthusiast
Enthusiast
Posts: 162
Joined: Mon May 10, 2010 4:02 pm

Re: YouTube Player

Post by kvitaliy »

Thanks, good work!
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: YouTube Player

Post 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
Last edited by JHPJHP on Mon Aug 07, 2017 8:27 am, edited 5 times in total.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: YouTube Player

Post 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
Fred
Administrator
Administrator
Posts: 16581
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: YouTube Player

Post by Fred »

Works perfectly :)
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: YouTube Player

Post by Kwai chang caine »

Again a good works :wink:
Thanks to sharing 8)
ImageThe happiness is a road...
Not a destination
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: YouTube Player

Post 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
Last edited by JHPJHP on Sun Aug 13, 2017 9:31 am, edited 4 times in total.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: YouTube Player

Post 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.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: YouTube Player

Post 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
Last edited by JHPJHP on Mon Aug 07, 2017 6:57 pm, edited 3 times in total.
Locked