i want to try streaming a twitch live video in android app in java through webView but the stream is mute and not in full screen in landscape mode.

Twitch live Video Streaming is working fine but i want 2 changes.

1. Stream start but on mute, but i have to unmute manually.
2. Stream not play in full screen even i add lanscape mode.

If you have any idea to solve these problem help me, I will be very grateful to you


import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import androidx.appcompat.app.AppCompatActivity;

import java.util.Calendar;

public class MainActivity extends AppCompatActivity {
    WebView mWebView;
    TextView textView;
    String url;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_main);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

        url = "https://player.twitch.tv/?channel=jandarpan_news&enableExtensions=true&muted=false&parent=twitch.tv&player=popout&quality=auto&volume=1";

        textView = (TextView) findViewById(R.id.textV);
        mWebView = (WebView) findViewById(R.id.webview1);
        mWebView.setWebChromeClient(new WebChromeClient());
        mWebView.setWebViewClient(new WebViewClient());

        WebSettings webSettings = mWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setUseWideViewPort(true);
        webSettings.setLoadWithOverviewMode(true);
        webSettings.setMediaPlaybackRequiresUserGesture(false);
       
        webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
        String userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36";
        webSettings.setUserAgentString(userAgent);
        mWebView.setLayerType(WebView.LAYER_TYPE_HARDWARE, null);
        mWebView.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onPermissionRequest(final android.webkit.PermissionRequest request) {
                request.grant(request.getResources());
            }
        });

        mWebView.loadUrl(url);
    }

}

0

There are 0 answers