[INFO:CONSOLE(0)] "Refused to frame 'https://player.twitch.tv/' because an ancestor violates the following Content Security Policy directive: "frame-ancestors https://onlinetesting"

Can anyone help me i want to play video stream embededin android app using android studio java but it error this

[INFO:CONSOLE(0)] "Refused to frame ‘https://player.twitch.tv/’ because an ancestor violates the following Content Security Policy directive: “frame-ancestors https://onlinetesting”.

    String clipUrl = "https://player.twitch.tv/?channel=kuyanicwxc&";


    String validUrl = "onlinetesting"; // Change this to your actual domain

    String html = "<iframe src=\"" + clipUrl + "&parent=" + validUrl +"\" height=\"360\" width=\"640\" allowfullscreen></iframe>";

    WebView mWebView = view.findViewById(R.id.webview);
    mWebView.setWebViewClient(new WebViewClient());
    mWebView.setWebChromeClient(new WebChromeClient());
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);

    mWebView.loadDataWithBaseURL(validUrl, html, "text/html", "UTF-8", null);

That is not a valid domain.

Your parent is incorrect

For a mobile app this should probably be localhost but it’s whatevers needed to get it to go. A similar to fix to electron apps should be applied if possible twitch_misc/player/electron at main · BarryCarlyon/twitch_misc · GitHub

I did have it working in android myself but I don’t have the code handy to provide. since I dropped the player and just redirect people to Twitch instead (I’ll dig it out if I can find my code)

im use localhost but its the same error result

please help me please

Nudging the post this quickly doesn’t help me help you

I’m digging out my code to have a look

I trying any method i search in internet but its not working… im stck 2 days on this huhuhuhuhuh

Ok so give me time to look rather than needless nudge. Aside from the fact I’m replying here instead of looking, you’ll hit the new user posting limit

your code is not for android studio java

I didn’t post any code yet, just an expected working parent

im newbie in coding sir so i cant understand the deep code specially when its mmy first time encounter… like this embed the video stream in app

The following URL works for me:

https://player.twitch.tv?channel=cohhcarnage&parent=com.cohhilition.cohhcarnage_mobile

You’ll need to substitute com.cohhilition.cohhcarnage_mobile for whatever your package ID is, since this is my package ID
Granted I’m using a webview library for flutter here, but it should follow over to whatever you are using.

The player here is below the purple button/above latest youtube

package com.example.onlineTest.ui.OnlineTestingFolder;
is this the package id?

still not working huhuhuhuh

Then I have no idea what the issue is as it works for me on a physical device using the URL into a generic/basic webview, granted mine works with any parent so I suspect my library is isolating things so that it just works regardless.

Not sure what you mean with this.

It’ll be whatever you set it to when creating the project.

not working

Don’t use an iFrame and/or load HTML set the web view to load the target URL.

You are iframing inside a frame and your parent stack is invalid as a result.

Which for me is a loadRequest rather than a loadDataWithBaseURL request.

For you that is loadUrl I belive instead


is this sir?

I don’t know refer to the documentation to see if it is that function call which I bvelive is WebViewClient  |  Android Developers for what you are using but I don’t know if that is what you are using

And it would be mWebView.loadURL(validUrl);

Not the HTML you don’t want an iFrame at all