Added Picure in picture
This commit is contained in:
parent
b1c212c2fc
commit
c5d1d5408b
|
@ -224,7 +224,8 @@
|
|||
|
||||
<activity
|
||||
android:name=".activity.VideoplayerActivity"
|
||||
android:configChanges="keyboardHidden|orientation"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize"
|
||||
android:supportsPictureInPicture="true"
|
||||
android:screenOrientation="sensorLandscape">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
|
|
|
@ -38,6 +38,7 @@ import de.danoeh.antennapod.core.feed.FeedItem;
|
|||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.service.playback.PlayerStatus;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.DBTasks;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
|
@ -225,10 +226,12 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
|
|||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
if (Build.VERSION.SDK_INT < 26 || !isInPictureInPictureMode()) {
|
||||
if (controller != null) {
|
||||
controller.reinitServiceIfPaused();
|
||||
controller.pause();
|
||||
}
|
||||
}
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ import android.os.Handler;
|
|||
import android.support.v4.view.WindowCompat;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.View;
|
||||
|
@ -96,10 +98,13 @@ public class VideoplayerActivity extends MediaplayerActivity {
|
|||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N
|
||||
|| !isInPictureInPictureMode()) {
|
||||
videoControlsHider.stop();
|
||||
if (controller != null && controller.getStatus() == PlayerStatus.PLAYING) {
|
||||
controller.pause();
|
||||
}
|
||||
}
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
|
@ -175,6 +180,10 @@ public class VideoplayerActivity extends MediaplayerActivity {
|
|||
|
||||
View.OnTouchListener onVideoviewTouched = (v, event) -> {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
|
||||
&& isInPictureInPictureMode()) {
|
||||
return true;
|
||||
}
|
||||
videoControlsHider.stop();
|
||||
toggleVideoControlsVisibility();
|
||||
if (videoControlsShowing) {
|
||||
|
@ -349,6 +358,26 @@ public class VideoplayerActivity extends MediaplayerActivity {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
menu.findItem(R.id.player_go_to_picture_in_picture).setVisible(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == R.id.player_go_to_picture_in_picture) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
enterPictureInPictureMode();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private static class VideoControlsHider extends Handler {
|
||||
|
||||
private static final int DELAY = 2500;
|
||||
|
|
|
@ -41,6 +41,14 @@
|
|||
android:title="@string/visit_website_label"
|
||||
android:visible="false">
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:id="@+id/player_go_to_picture_in_picture"
|
||||
custom:showAsAction="collapseActionView"
|
||||
android:title="@string/player_go_to_picture_in_picture"
|
||||
android:visible="false">
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:id="@+id/share_item"
|
||||
android:icon="?attr/social_share"
|
||||
|
|
|
@ -234,6 +234,7 @@
|
|||
<string name="no_media_playing_label">No media playing</string>
|
||||
<string name="position_default_label" translate="false">00:00:00</string>
|
||||
<string name="player_buffering_msg">Buffering</string>
|
||||
<string name="player_go_to_picture_in_picture">Picture-in-picture mode</string>
|
||||
<string name="playbackservice_notification_title">Playing podcast</string>
|
||||
<string name="unknown_media_key">AntennaPod - Unknown media key: %1$d</string>
|
||||
|
||||
|
|
Loading…
Reference in New Issue