Jump to content
Yaron

YouTube playback & control using WebView2 on Delphi 7

Recommended Posts

This is a tough one, I need advice.

 

I currently offer the option to play YouTube video content in my Delphi 7 app by using YouTube's IFRAME player and Javascript API inside a TWebBrowser component.

 

Unfortunately, the TWebBrowser component is limited to the Edge Legacy engine (Edge v11) and is dropping frames like crazy, which is why I would like to move the code to use the Edge Chromium engine.

 

Previously, Microsoft let you choose the engine by specifying a registry key (HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION), but it seems that with the Chromium version, they dumped the old IWebBrowser interface for a new WebView2 interface.

 

Unfortunately, I haven't found any WebView2 support for Delphi 7. It seems WebView2 support was only introduced in Delphi 10.4 and I only own Delphi 10.3 and can't afford paying $1000+ just for this feature.

 

I'm aware of Delphi Chromium Embeded 3 project, but it may have legal issues with the decoders required to play YouTube content, so it's not an option.

 

So the questions are:

  1. Can I hire someone to write a DLL I can then use in Delphi 7, giving me the functionality I need (video position within my window handle and a Javascript bridge to the YouTube API data/events)?
  2. Is there a WebView2 implementation that I missed and is compatible with Delphi 7 or at least would allow me to generate a DLL I can use in Delphi 7, but write in Delphi 10.3?
  3. Is there an option I haven't considered?
Edited by Yaron

Share this post


Link to post
52 minutes ago, Yaron said:

Can I hire someone to write a DLL

How much are you ready to pay for such a DLL?

Would probably cost more than upgrading your Delphi version.

 

Share this post


Link to post
20 hours ago, Yaron said:

I'm aware of Delphi Chromium Embeded 3 project, but it may have legal issues with the decoders required to play YouTube content, so it's not an option

This sounds weird to me.

20 hours ago, Yaron said:

Unfortunately, I haven't found any WebView2 support for Delphi 7. It seems WebView2 support was only introduced in Delphi 10.4 and I only own Delphi 10.3 and can't afford paying $1000+ just for this feature.

Well, "support" is very likely just a wrapper unit, I guess you can borrow* it from 10.4 ISO. Or try 10.4 CE.

 

-----

* borrow (here): read unit's source, close it, wait for several days and write your own implementation surely not using any 1:1 original code except for a pure inspiration.

Edited by Fr0sT.Brutal
clarify term

Share this post


Link to post

Evaluation versions do not come with source code, and the Community Edition with "limited" RTL source code (whatever that means).

 

Your understanding of "borrowing" however even seems even weirder.

Share this post


Link to post
3 hours ago, Der schöne Günther said:

Evaluation versions do not come with source code, and the Community Edition with "limited" RTL source code (whatever that means).

Source code is not needed if OP would create a DLL with some of these options.

3 hours ago, Der schöne Günther said:

Your understanding of "borrowing" however even seems even weirder.

I added clarification to make you and Emba's lawyers calm ;)

Edited by Fr0sT.Brutal

Share this post


Link to post
4 hours ago, Fr0sT.Brutal said:

This sounds weird to me.

@Fr0sT.Brutal It's the H.264 codec and AAC audio, it's sort of gray legally, but I'd rather avoid any such hassle.

 

@FPiette

Probably around $200. It's basically a wrap-up job with minimal logic (I'm doing the YouTube/javascript code, I just need access to the component/events and bridge to javascript commands/events.

 

Share this post


Link to post
1 hour ago, Yaron said:

Probably around $200.

Not many work hours into that price.

Why don't you use Delphi community edition to build the DLL yourself? Later you can ask someone with a valid license recompile it for you.

Share this post


Link to post
On 10/19/2021 at 4:59 PM, Yaron said:

I'm aware of Delphi Chromium Embeded 3 project, but it may have legal issues with the decoders required to play YouTube content, so it's not an option.

Not sure if you mean Cef4Delphi ?

This one is always quite actual.

Share this post


Link to post
17 hours ago, Yaron said:

It's the H.264 codec and AAC audio, it's sort of gray legally, but I'd rather avoid any such hassle.

I have no idea about legality and pretty sure you considered that but doesn't playback via ffdshow solve the problem?

Share this post


Link to post
On 10/21/2021 at 10:37 AM, Fr0sT.Brutal said:

I have no idea about legality and pretty sure you considered that but doesn't playback via ffdshow solve the problem?

If you mean using DirectShow, there was a filter for that, but it's no longer functioning correctly after youtube changed something server-side and the developer is no longer responsive.

 

Share this post


Link to post

 

On 10/26/2021 at 10:44 AM, Fr0sT.Brutal said:

Hmm, https://www.ffmpeg.org/index.html#news seems pretty fresh and it's used by youtube-dl for decoding YT videos so it should work.

From what I can tell, the problem is that YouTube is now detecting non-valid clients and then putting a bandwidth limiter on the connection, making playback unpractical.

At least that's I experience when trying to use the D3YD YouTube Directshow filter.

 

 

On 10/21/2021 at 12:11 AM, Kevin Koehne said:

We use this component with D2007. It appears to support most versions of Delphi.

https://winsoft.sk/webview.htm

I am experimenting with it now, I can get it to load the video, but I'm still not sure how to capture javascript event and send the event's data back to Delphi.

 

Share this post


Link to post
17 hours ago, Yaron said:

From what I can tell, the problem is that YouTube is now detecting non-valid clients and then putting a bandwidth limiter on the connection, making playback unpractical.

How a browser component could be non-valid? They must be limiting all browsers then which doesn't happen obviously. Maybe server expects some headers to distinguish standalone browser from an embedded component, try to mimic them

Edited by Fr0sT.Brutal

Share this post


Link to post
5 hours ago, Fr0sT.Brutal said:

How a browser component could be non-valid? They must be limiting all browsers then which doesn't happen obviously. Maybe server expects some headers to distinguish standalone browser from an embedded component, try to mimic them

Sorry if I wasn't clear, I was referring to DirectShow which does not use a browser component. It does use http transport and you can specify the user-agent, but it makes no difference, somehow YouTube identifies it and limits the bandwidth to unusable levels.

Share this post


Link to post
On 11/12/2021 at 5:34 PM, Yaron said:

Sorry if I wasn't clear, I was referring to DirectShow which does not use a browser component. It does use http transport and you can specify the user-agent, but it makes no difference, somehow YouTube identifies it and limits the bandwidth to unusable levels.

Then you'll have to download a video by yourself fully controlling HTTP headers and feed resulting data to video player component

Share this post


Link to post

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

×