TTMSFNCWXContainer -> Youtube video : Watch video on YouTube Error 153 Video player configuration error

Hello,

Playing Youtube videos with Gives : “Watch video on YouTube Error 153 Video player configuration error“ text on the TTMSFNCWXContainer.
I use an FMX application, I don’t know if this changes anything → I found that TTMSFNCWXContainer has different properties on VCL and FMX.
Thank you!

Hi,

Could you provide us with the HTML, CSS and JavaScript so that we can test on our end.

Regards

Project2_2026-01-26_19-55-04.zip (9.8 KB)
Hi,
I uploaded a project where I want to call your own video , “Flexible filtering in your VCL, FMX and WEB apps with TTMSFNCFilterView“
What I did was that I copied the Share Embedded Video link and put it in the ElementContainers[0].HTML.

Thank you!

Hello Bradley,

Could you test it? Thank you.

Hi,

Sorry for the delayed response. We are investigating the issue, and it appears more complex than we thought it to be. Youtube has changed some policies regarding embedded video’s and we are researching if we can find a way around them. We will get back to you when we find a solution.

With kind regards

Hi,

While we continue to investigate this, perhaps this is a workaround you can use if you are targetting Windows only. It involves using TTMSFNCWebBrowser to mimic a localhost server and append the necessary Referer header:

uses
  FMX.TMSFNCWebBrowser.Win;

type
  TCoreWebView2WebResourceRequestedEventHandler = class(TInterfacedObject, ICoreWebView2WebResourceRequestedEventHandler)
    function Invoke(sender: ICoreWebView2; args: ICoreWebView2WebResourceRequestedEventArgs): HRESULT; stdcall;
  end;

procedure TForm22.TMSFNCWebBrowser1Initialized(Sender: TObject);
var
  c: ICoreWebView2Controller;
  w: ICoreWebView2;
  e: EventRegistrationToken;
begin
  c := ICoreWebView2Controller(TMSFNCWebBrowser1.NativeBrowser);
  if c.get_CoreWebView2(w) = S_OK then
  begin
    w.add_WebResourceRequested(TCoreWebView2WebResourceRequestedEventHandler.Create, @e);
    w.AddWebResourceRequestedFilter('*', COREWEBVIEW2_WEB_RESOURCE_CONTEXT_DOCUMENT);
  end;

  TMSFNCWebBrowser1.URL := 'http://localhost:8888/youtube.html';
end;

{ TCoreWebView2WebResourceRequestedEventHandler }

function TCoreWebView2WebResourceRequestedEventHandler.Invoke(
  sender: ICoreWebView2;
  args: ICoreWebView2WebResourceRequestedEventArgs): HRESULT;
const
  LB = #13#10;
  s =
  '<!DOCTYPE html>' + LB +
  '<html>' + LB +
  '<body>' + LB +

  '<iframe width="560" height="315" src="https://www.youtube.com/embed/oeGdDMOIJWI?si=ZXkHJp6TaClsnDRo" title="YouTube video player" frameborder="0" allow="accelerometer;' +
  'autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>' + LB +

  '</body>' + LB +
  '</html>';
var
  r: ICoreWebView2WebResourceRequest;
  ms: TStringStream;
  st: TStreamAdapter;
  rs: ICoreWebView2WebResourceResponse;
  e: ICoreWebView2Environment;
  uri: PWideChar;
  h: ICoreWebView2HttpResponseHeaders;
begin
  if args.get_Request(r) = S_OK then
  begin
    r.get_Uri(@uri);
    if uri = 'http://localhost:8888/youtube.html' then
    begin
      ms := TStringStream.Create;
      try
        ms.WriteString(s);
        st := TStreamAdapter.Create(ms, soOwned);
        e := ICoreWebView2Environment(Form22.TMSFNCWebBrowser1.NativeEnvironment);
        e.CreateWebResourceResponse(st, 200, 'OK', 'charset=utf-8', rs);

        rs.get_Headers(h);
        h.AppendHeader('Referer', 'https://localhost/');

        args.put_Response(rs);
      finally
      end;
    end;
  end;

  Result := S_OK;
end;
1 Like

Hi Tünde,

Thank you very much. Primarily I wanted to use it on Android, but it is good to know this workaround.

Have a nice day!