basic pip function

This commit is contained in:
Page Asgardius 2022-10-09 12:09:30 -07:00
parent 4adc3c5a7a
commit 307e1253de
4 changed files with 73 additions and 41 deletions

View file

@ -7,7 +7,7 @@ android {
defaultConfig { defaultConfig {
applicationId "asgardius.page.s3manager" applicationId "asgardius.page.s3manager"
minSdk 24 minSdk 23
targetSdk 33 targetSdk 33
versionCode 27 versionCode 27
versionName "0.1.25" versionName "0.1.25"

View file

@ -86,9 +86,11 @@
android:label="@string/bucket_list" /> android:label="@string/bucket_list" />
<activity <activity
android:name=".VideoPlayer" android:name=".VideoPlayer"
android:configChanges="orientation|keyboardHidden|screenSize|uiMode|keyboardHidden" android:resizeableActivity="true"
android:supportsPictureInPicture="true"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|uiMode|keyboardHidden"
android:exported="false" android:exported="false"
android:theme="@style/Theme.AsgardiusS3Manager.Fullscreen" /> android:theme="@style/Theme.AsgardiusS3Manager.NoActionBar" />
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize|uiMode|keyboardHidden" android:configChanges="orientation|keyboardHidden|screenSize|uiMode|keyboardHidden"

View file

@ -2,6 +2,7 @@ package asgardius.page.s3manager;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.EditText; import android.widget.EditText;
@ -31,7 +32,7 @@ public class TextViewer extends AppCompatActivity {
setContentView(R.layout.activity_text_viewer); setContentView(R.layout.activity_text_viewer);
filecontent = (EditText)findViewById(R.id.textShow); filecontent = (EditText)findViewById(R.id.textShow);
final ProgressBar simpleProgressBar = (ProgressBar) findViewById(R.id.simpleProgressBar); final ProgressBar simpleProgressBar = (ProgressBar) findViewById(R.id.simpleProgressBar);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
String videoURL = getIntent().getStringExtra("video_url"); String videoURL = getIntent().getStringExtra("video_url");
Thread textread = new Thread(new Runnable() { Thread textread = new Thread(new Runnable() {
@ -75,6 +76,9 @@ public class TextViewer extends AppCompatActivity {
} }
}); });
textread.start(); textread.start();
} else {
finish();
}
/*try { /*try {
// Create a URL for the desired page // Create a URL for the desired page

View file

@ -2,9 +2,12 @@ package asgardius.page.s3manager;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.app.PictureInPictureParams;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager;
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.Bundle; import android.os.Bundle;
import android.os.PowerManager; import android.os.PowerManager;
import android.view.View; import android.view.View;
@ -49,15 +52,16 @@ public class VideoPlayer extends AppCompatActivity {
DefaultLoadControl loadControl; DefaultLoadControl loadControl;
DefaultRenderersFactory renderersFactory; DefaultRenderersFactory renderersFactory;
ExoPlayer player; ExoPlayer player;
long videoPosition;
@Override @Override
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);
// create Wifi and wake locks // create Wifi and wake locks
mWifiLock = ((WifiManager) this.getApplicationContext().getSystemService(Context.WIFI_SERVICE)).createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "Transistor:wifi_lock"); mWifiLock = ((WifiManager) this.getApplicationContext().getSystemService(Context.WIFI_SERVICE)).createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "S3Manager:wifi_lock");
powerManager = (PowerManager) getSystemService(POWER_SERVICE); powerManager = (PowerManager) getSystemService(POWER_SERVICE);
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Transistor:wake_lock"); mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "S3Manager:wake_lock");
//Get media url //Get media url
String videoURL = getIntent().getStringExtra("video_url"); String videoURL = getIntent().getStringExtra("video_url");
videocache = getIntent().getIntExtra("videocache", 40); videocache = getIntent().getIntExtra("videocache", 40);
@ -163,6 +167,22 @@ public class VideoPlayer extends AppCompatActivity {
}); });
} }
protected void enterPIPMode() {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
&& this.getPackageManager()
.hasSystemFeature(
PackageManager.FEATURE_PICTURE_IN_PICTURE)) {
videoPosition = player.getCurrentPosition();
playerView.setUseController(false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
PictureInPictureParams params = new PictureInPictureParams.Builder().build();
this.enterPictureInPictureMode(params);
}else {
this.enterPictureInPictureMode();
}
}
}
@Override @Override
public void onWindowFocusChanged(boolean hasFocus) { public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus); super.onWindowFocusChanged(hasFocus);
@ -181,11 +201,17 @@ public class VideoPlayer extends AppCompatActivity {
public void onDestroy() { public void onDestroy() {
simpleCache.release(); simpleCache.release();
playerView.setPlayer(null);
player.release(); player.release();
super.onDestroy(); super.onDestroy();
} }
public void onUserLeaveHint() {
super.onUserLeaveHint();
enterPIPMode();
}
/*public void onBackPressed() { /*public void onBackPressed() {
player.release(); player.release();
finish(); finish();