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;
import android.app.AppOpsManager;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PictureInPictureParams;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.hardware.display.DisplayManager;
import android.net.Uri;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Bundle;
import android.os.PowerManager;
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 androidx.appcompat.app.AppCompatActivity;
@ -68,13 +60,11 @@ public class VideoPlayer extends AppCompatActivity {
long videoPosition;
MediaSessionCompat mediaSession;
MediaSessionConnector mediaSessionConnector;
StyledPlayerView.ControllerVisibilityListener control;
private PlayerNotificationManager playerNotificationManager;
private int notificationId = 1234;
boolean isplaylist;
boolean success = false;
String videoURL, title;
Rational ratio;
public static String URLify(String str) {
str = str.trim();
@ -110,9 +100,6 @@ public class VideoPlayer extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
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){
NotificationChannel channel= new NotificationChannel("playback","Video Playback", NotificationManager.IMPORTANCE_DEFAULT);
@ -122,7 +109,6 @@ public class VideoPlayer extends AppCompatActivity {
}
mediaSession = new MediaSessionCompat(this, getPackageName());
mediaSessionConnector = new MediaSessionConnector(mediaSession);
hideSystemBars();
AudioAttributes audioAttributes = new AudioAttributes.Builder()
.setUsage(C.USAGE_MEDIA)
.setContentType(C.AUDIO_CONTENT_TYPE_MOVIE)
@ -159,17 +145,7 @@ public class VideoPlayer extends AppCompatActivity {
evictor,
standaloneDatabaseProvider);
playerView.setPlayer(player);
control = new StyledPlayerView.ControllerVisibilityListener() {
@Override
public void onVisibilityChanged(int visibility) {
if (playerView.isControllerFullyVisible()) {
showSystemBars();
} else {
hideSystemBars();
}
}
};
playerView.setControllerVisibilityListener(control);
playerView.setUseController(false);
//MediaItem mediaItem = MediaItem.fromUri(videoURL);
// 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
public void onDestroy() {
@ -333,15 +287,6 @@ public class VideoPlayer extends AppCompatActivity {
super.onDestroy();
}
public void onResume(){
super.onResume();
// put your code here...
if (!playerView.getUseController()) {
playerView.setUseController(true);
}
hideSystemBars();
}
protected void onNewIntent(Intent intent) {
videoURL = intent.getStringExtra("video_url");
title = intent.getStringExtra("title");

View file

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