Project

General

Profile

« Previous | Next » 

Revision 00231eb1

Added by Leszek Koltunski 2 days ago

fix for YouTube tightening its policy

View differences:

src/main/java/org/distorted/tutorials/TutorialWebView.java
10 10
package org.distorted.tutorials;
11 11

  
12 12
import android.annotation.SuppressLint;
13
import android.webkit.WebSettings;
13 14
import android.webkit.WebView;
14 15
import android.webkit.WebViewClient;
15 16

  
......
27 28
      {
28 29
      mWebView = webview;
29 30
      mWebView.setBackgroundColor(0);
30
      mWebView.getSettings().setJavaScriptEnabled(true);
31 31

  
32
      mWebView.setWebViewClient(new WebViewClient()
33
        {
34
        @Override
35
        public boolean shouldOverrideUrlLoading(WebView view, String url)
36
          {
37
          return false;
38
          }
39
        });
32
      WebSettings ws = mWebView.getSettings();
33
      ws.setJavaScriptEnabled(true);
34
      ws.setDomStorageEnabled(true);
35
      ws.setMediaPlaybackRequiresUserGesture(false);
36

  
37
      mWebView.setWebViewClient(new WebViewClient());
40 38
      }
41 39

  
42 40
///////////////////////////////////////////////////////////////////////////////////////////////////
......
45 43
      {
46 44
      mUrl = url;
47 45

  
48
      String data1 = "<html><body><iframe width=\"100%\" height=\"100%\" src=\"";
49
      String data2 = "\" frameborder=\"0\" allowfullscreen></iframe></body></html>";
50

  
51
      mWebView.loadData(data1+url+data2, "text/html", "UTF-8");
46
      String baseUrl = "https://distorted.org/";
47

  
48
      String html =
49
              "<html>" +
50
              "<body style='margin:0;padding:0'>" +
51
              "<iframe " +
52
              "width='100%' height='100%' " +
53
              "src='" + url + "' " +
54
              "frameborder='0' " +
55
              "allow='autoplay; encrypted-media' " +
56
              "referrerpolicy='strict-origin-when-cross-origin' " +
57
              "allowfullscreen>" +
58
              "</iframe>" +
59
              "</body></html>";
60

  
61
      mWebView.loadDataWithBaseURL(baseUrl, html,"text/html", "UTF-8",null);
52 62
      }
53 63

  
54 64
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff