mirror of
https://framagit.org/tom79/nitterizeme
synced 2025-02-03 10:47:29 +01:00
Built in player
This commit is contained in:
parent
16fb1cfb8e
commit
fe7c0fb25b
@ -186,7 +186,7 @@
|
||||
<activity android:name="app.fedilab.nitterizeme.WebviewPlayerActivity"
|
||||
android:label="@string/app_name"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"/>
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar.FullScreen"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -25,6 +25,8 @@ import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import org.jsoup.Jsoup;
|
||||
@ -36,7 +38,9 @@ public class WebviewPlayerActivity extends AppCompatActivity {
|
||||
|
||||
private String videoUrl;
|
||||
private WebView webView;
|
||||
private RelativeLayout loader;
|
||||
private BroadcastReceiver receive_data;
|
||||
private FrameLayout webview_container;
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -54,7 +58,8 @@ public class WebviewPlayerActivity extends AppCompatActivity {
|
||||
|
||||
final ViewGroup videoLayout = findViewById(R.id.videoLayout);
|
||||
webView = findViewById(R.id.webview);
|
||||
FrameLayout webview_container = findViewById(R.id.webview_container);
|
||||
loader = findViewById(R.id.loader);
|
||||
webview_container = findViewById(R.id.webview_container);
|
||||
webView.getSettings().setJavaScriptEnabled(true);
|
||||
|
||||
PlayerChromeClient playerChromeClient = new PlayerChromeClient(WebviewPlayerActivity.this, webView, webview_container, videoLayout);
|
||||
@ -85,12 +90,14 @@ public class WebviewPlayerActivity extends AppCompatActivity {
|
||||
if (streaming_url != null ) {
|
||||
webView.stopLoading();
|
||||
webView.loadUrl(streaming_url);
|
||||
loader.setVisibility(View.GONE);
|
||||
webview_container.setVisibility(View.VISIBLE);
|
||||
videoLayout.setVisibility(View.VISIBLE);
|
||||
WindowManager.LayoutParams attrs = getWindow().getAttributes();
|
||||
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
||||
attrs.flags &= ~WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
||||
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
||||
attrs.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
||||
getWindow().setAttributes(attrs);
|
||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
|
||||
videoLayout.setVisibility(View.GONE);
|
||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -108,9 +115,7 @@ public class WebviewPlayerActivity extends AppCompatActivity {
|
||||
Element source = video.select("source").first();
|
||||
if( source != null ) {
|
||||
videoUrl = source.absUrl("src");
|
||||
runOnUiThread(() -> {
|
||||
webView.loadUrl(videoUrl);
|
||||
});
|
||||
runOnUiThread(() -> webView.loadUrl(videoUrl));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,9 +19,12 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/black"
|
||||
tools:context=".WebviewPlayerActivity">
|
||||
<FrameLayout
|
||||
android:id="@+id/webview_container"
|
||||
android:background="@android:color/black"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
@ -38,4 +41,13 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone" />
|
||||
<RelativeLayout
|
||||
android:id="@+id/loader"
|
||||
android:gravity="center"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<ProgressBar
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
@ -41,11 +41,13 @@
|
||||
</style>
|
||||
|
||||
|
||||
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light.NoActionBar">
|
||||
<style name="Theme.AppCompat.NoActionBar.FullScreen" parent="Theme.AppCompat.NoActionBar">
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<item name="android:windowActionBar">false</item>
|
||||
<item name="android:windowFullscreen">true</item>
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
<item name="android:windowBackground">#000000</item>
|
||||
<item name="android:colorBackground">#000000</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user