first step

This commit is contained in:
Page Asgardius 2023-02-23 13:43:21 -07:00
parent 906eb64847
commit 4af39b75e2
2 changed files with 3 additions and 59 deletions

View file

@ -1,23 +1,15 @@
package asgardius.page.s3music; package asgardius.page.s3music;
import android.app.AppOpsManager;
import android.app.NotificationChannel; import android.app.NotificationChannel;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.PictureInPictureParams;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager;
import android.hardware.display.DisplayManager;
import android.net.Uri; import android.net.Uri;
import android.net.wifi.WifiManager; import android.net.wifi.WifiManager;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.PowerManager; import android.os.PowerManager;
import android.support.v4.media.session.MediaSessionCompat; import android.support.v4.media.session.MediaSessionCompat;
import android.util.Rational;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.Toast; import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
@ -68,13 +60,11 @@ public class VideoPlayer extends AppCompatActivity {
long videoPosition; long videoPosition;
MediaSessionCompat mediaSession; MediaSessionCompat mediaSession;
MediaSessionConnector mediaSessionConnector; MediaSessionConnector mediaSessionConnector;
StyledPlayerView.ControllerVisibilityListener control;
private PlayerNotificationManager playerNotificationManager; private PlayerNotificationManager playerNotificationManager;
private int notificationId = 1234; private int notificationId = 1234;
boolean isplaylist; boolean isplaylist;
boolean success = false; boolean success = false;
String videoURL, title; String videoURL, title;
Rational ratio;
public static String URLify(String str) { public static String URLify(String str) {
str = str.trim(); str = str.trim();
@ -110,9 +100,6 @@ public class VideoPlayer extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_player); setContentView(R.layout.activity_video_player);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
}
if(Build.VERSION.SDK_INT >=Build.VERSION_CODES.O){ if(Build.VERSION.SDK_INT >=Build.VERSION_CODES.O){
NotificationChannel channel= new NotificationChannel("playback","Video Playback", NotificationManager.IMPORTANCE_DEFAULT); NotificationChannel channel= new NotificationChannel("playback","Video Playback", NotificationManager.IMPORTANCE_DEFAULT);
@ -122,7 +109,6 @@ public class VideoPlayer extends AppCompatActivity {
} }
mediaSession = new MediaSessionCompat(this, getPackageName()); mediaSession = new MediaSessionCompat(this, getPackageName());
mediaSessionConnector = new MediaSessionConnector(mediaSession); mediaSessionConnector = new MediaSessionConnector(mediaSession);
hideSystemBars();
AudioAttributes audioAttributes = new AudioAttributes.Builder() AudioAttributes audioAttributes = new AudioAttributes.Builder()
.setUsage(C.USAGE_MEDIA) .setUsage(C.USAGE_MEDIA)
.setContentType(C.AUDIO_CONTENT_TYPE_MOVIE) .setContentType(C.AUDIO_CONTENT_TYPE_MOVIE)
@ -159,17 +145,7 @@ public class VideoPlayer extends AppCompatActivity {
evictor, evictor,
standaloneDatabaseProvider); standaloneDatabaseProvider);
playerView.setPlayer(player); playerView.setPlayer(player);
control = new StyledPlayerView.ControllerVisibilityListener() { playerView.setUseController(false);
@Override
public void onVisibilityChanged(int visibility) {
if (playerView.isControllerFullyVisible()) {
showSystemBars();
} else {
hideSystemBars();
}
}
};
playerView.setControllerVisibilityListener(control);
//MediaItem mediaItem = MediaItem.fromUri(videoURL); //MediaItem mediaItem = MediaItem.fromUri(videoURL);
// Set the media item to be played. // Set the media item to be played.
@ -289,28 +265,6 @@ public class VideoPlayer extends AppCompatActivity {
}); });
} }
private void hideSystemBars() {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hide and show.
Objects.requireNonNull(getSupportActionBar()).hide();
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE);
}
private void showSystemBars() {
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
Objects.requireNonNull(getSupportActionBar()).show();
}
@Override @Override
public void onDestroy() { public void onDestroy() {
@ -333,15 +287,6 @@ public class VideoPlayer extends AppCompatActivity {
super.onDestroy(); super.onDestroy();
} }
public void onResume(){
super.onResume();
// put your code here...
if (!playerView.getUseController()) {
playerView.setUseController(true);
}
hideSystemBars();
}
protected void onNewIntent(Intent intent) { protected void onNewIntent(Intent intent) {
videoURL = intent.getStringExtra("video_url"); videoURL = intent.getStringExtra("video_url");
title = intent.getStringExtra("title"); title = intent.getStringExtra("title");

View file

@ -3,7 +3,6 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/black"
android:theme="@style/ThemeOverlay.AsgardiusS3Manager.FullscreenContainer" android:theme="@style/ThemeOverlay.AsgardiusS3Manager.FullscreenContainer"
tools:context=".VideoPlayer"> tools:context=".VideoPlayer">
@ -15,8 +14,8 @@
android:id="@+id/player_view" android:id="@+id/player_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:keepScreenOn="true" android:layout_marginBottom="200dp"
android:padding="0dp"/> android:padding="20dp"/>
</FrameLayout> </FrameLayout>