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