basic pip function
This commit is contained in:
parent
4adc3c5a7a
commit
307e1253de
4 changed files with 73 additions and 41 deletions
|
@ -7,7 +7,7 @@ android {
|
|||
|
||||
defaultConfig {
|
||||
applicationId "asgardius.page.s3manager"
|
||||
minSdk 24
|
||||
minSdk 23
|
||||
targetSdk 33
|
||||
versionCode 27
|
||||
versionName "0.1.25"
|
||||
|
|
|
@ -86,9 +86,11 @@
|
|||
android:label="@string/bucket_list" />
|
||||
<activity
|
||||
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:theme="@style/Theme.AsgardiusS3Manager.Fullscreen" />
|
||||
android:theme="@style/Theme.AsgardiusS3Manager.NoActionBar" />
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize|uiMode|keyboardHidden"
|
||||
|
|
|
@ -2,6 +2,7 @@ package asgardius.page.s3manager;
|
|||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
@ -31,50 +32,53 @@ public class TextViewer extends AppCompatActivity {
|
|||
setContentView(R.layout.activity_text_viewer);
|
||||
filecontent = (EditText)findViewById(R.id.textShow);
|
||||
final ProgressBar simpleProgressBar = (ProgressBar) findViewById(R.id.simpleProgressBar);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
String videoURL = getIntent().getStringExtra("video_url");
|
||||
Thread textread = new Thread(new Runnable() {
|
||||
|
||||
String videoURL = getIntent().getStringExtra("video_url");
|
||||
Thread textread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
//Your code goes here
|
||||
URL fileurl = new URL(videoURL);
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
//Your code goes here
|
||||
URL fileurl = new URL(videoURL);
|
||||
// Read all the text returned by the server
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(fileurl.openStream()));
|
||||
String str = in.lines().collect(Collectors.joining());
|
||||
in.close();
|
||||
|
||||
// Read all the text returned by the server
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(fileurl.openStream()));
|
||||
String str = in.lines().collect(Collectors.joining());
|
||||
in.close();
|
||||
runOnUiThread(new Runnable() {
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Sending reference and data to Adapter
|
||||
simpleProgressBar.setVisibility(View.INVISIBLE);
|
||||
filecontent.setText(str);
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// Sending reference and data to Adapter
|
||||
simpleProgressBar.setVisibility(View.INVISIBLE);
|
||||
filecontent.setText(str);
|
||||
}
|
||||
});
|
||||
//System.out.println("tree "+treelevel);
|
||||
//System.out.println("prefix "+prefix);
|
||||
|
||||
}
|
||||
});
|
||||
//System.out.println("tree "+treelevel);
|
||||
//System.out.println("prefix "+prefix);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
runOnUiThread(new Runnable() {
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
runOnUiThread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
textread.start();
|
||||
});
|
||||
textread.start();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
|
||||
/*try {
|
||||
// Create a URL for the desired page
|
||||
|
|
|
@ -2,9 +2,12 @@ package asgardius.page.s3manager;
|
|||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.app.PictureInPictureParams;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.view.View;
|
||||
|
@ -49,15 +52,16 @@ public class VideoPlayer extends AppCompatActivity {
|
|||
DefaultLoadControl loadControl;
|
||||
DefaultRenderersFactory renderersFactory;
|
||||
ExoPlayer player;
|
||||
long videoPosition;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_video_player);
|
||||
// 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);
|
||||
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Transistor:wake_lock");
|
||||
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "S3Manager:wake_lock");
|
||||
//Get media url
|
||||
String videoURL = getIntent().getStringExtra("video_url");
|
||||
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
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
|
@ -181,11 +201,17 @@ public class VideoPlayer extends AppCompatActivity {
|
|||
|
||||
public void onDestroy() {
|
||||
simpleCache.release();
|
||||
playerView.setPlayer(null);
|
||||
player.release();
|
||||
super.onDestroy();
|
||||
|
||||
}
|
||||
|
||||
public void onUserLeaveHint() {
|
||||
super.onUserLeaveHint();
|
||||
enterPIPMode();
|
||||
}
|
||||
|
||||
/*public void onBackPressed() {
|
||||
player.release();
|
||||
finish();
|
||||
|
|
Loading…
Reference in a new issue