Merge branch 'dev' into master
18
README.md
|
@ -20,15 +20,15 @@
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
||||||
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_1.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_1.png)
|
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_01.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_01.png)
|
||||||
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_2.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_2.png)
|
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_02.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_02.png)
|
||||||
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_3.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_3.png)
|
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_03.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_03.png)
|
||||||
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_4.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_4.png)
|
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_04.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_04.png)
|
||||||
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_5.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_5.png)
|
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_05.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_05.png)
|
||||||
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_6.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_6.png)
|
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_06.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_06.png)
|
||||||
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_7.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_7.png)
|
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_07.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_07.png)
|
||||||
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_8.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_8.png)
|
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_08.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_08.png)
|
||||||
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_9.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_9.png)
|
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_09.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_09.png)
|
||||||
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_10.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_10.png)
|
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_10.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_10.png)
|
||||||
[<img src="fastlane/metadata/android/en-US/images/tenInchScreenshots/shot_11.png" width=405>](fastlane/metadata/android/en-US/images/tenInchScreenshots/shot_11.png)
|
[<img src="fastlane/metadata/android/en-US/images/tenInchScreenshots/shot_11.png" width=405>](fastlane/metadata/android/en-US/images/tenInchScreenshots/shot_11.png)
|
||||||
[<img src="fastlane/metadata/android/en-US/images/tenInchScreenshots/shot_12.png" width=405>](fastlane/metadata/android/en-US/images/tenInchScreenshots/shot_12.png)
|
[<img src="fastlane/metadata/android/en-US/images/tenInchScreenshots/shot_12.png" width=405>](fastlane/metadata/android/en-US/images/tenInchScreenshots/shot_12.png)
|
||||||
|
|
|
@ -6,7 +6,7 @@ android {
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "org.schabi.newpipe"
|
applicationId "org.schabi.newpipe"
|
||||||
minSdkVersion 15
|
minSdkVersion 19
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode 69
|
versionCode 69
|
||||||
versionName "0.14.2"
|
versionName "0.14.2"
|
||||||
|
|
|
@ -542,8 +542,7 @@ public class RouterActivity extends AppCompatActivity {
|
||||||
|
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
boolean isExtVideoEnabled = preferences.getBoolean(getString(R.string.use_external_video_player_key), false);
|
boolean isExtVideoEnabled = preferences.getBoolean(getString(R.string.use_external_video_player_key), false);
|
||||||
boolean isExtAudioEnabled = preferences.getBoolean(getString(R.string.use_external_audio_player_key), false);
|
boolean isExtAudioEnabled = preferences.getBoolean(getString(R.string.use_external_audio_player_key), false);;
|
||||||
boolean useOldVideoPlayer = PlayerHelper.isUsingOldPlayer(this);
|
|
||||||
|
|
||||||
PlayQueue playQueue;
|
PlayQueue playQueue;
|
||||||
String playerChoice = choice.playerChoice;
|
String playerChoice = choice.playerChoice;
|
||||||
|
@ -555,9 +554,6 @@ public class RouterActivity extends AppCompatActivity {
|
||||||
} else if (playerChoice.equals(videoPlayerKey) && isExtVideoEnabled) {
|
} else if (playerChoice.equals(videoPlayerKey) && isExtVideoEnabled) {
|
||||||
NavigationHelper.playOnExternalVideoPlayer(this, (StreamInfo) info);
|
NavigationHelper.playOnExternalVideoPlayer(this, (StreamInfo) info);
|
||||||
|
|
||||||
} else if (playerChoice.equals(videoPlayerKey) && useOldVideoPlayer) {
|
|
||||||
NavigationHelper.playOnOldVideoPlayer(this, (StreamInfo) info);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
playQueue = new SinglePlayQueue((StreamInfo) info);
|
playQueue = new SinglePlayQueue((StreamInfo) info);
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,6 @@ import org.schabi.newpipe.local.history.HistoryRecordManager;
|
||||||
import org.schabi.newpipe.player.MainVideoPlayer;
|
import org.schabi.newpipe.player.MainVideoPlayer;
|
||||||
import org.schabi.newpipe.player.PopupVideoPlayer;
|
import org.schabi.newpipe.player.PopupVideoPlayer;
|
||||||
import org.schabi.newpipe.player.helper.PlayerHelper;
|
import org.schabi.newpipe.player.helper.PlayerHelper;
|
||||||
import org.schabi.newpipe.player.old.PlayVideoActivity;
|
|
||||||
import org.schabi.newpipe.player.playqueue.PlayQueue;
|
import org.schabi.newpipe.player.playqueue.PlayQueue;
|
||||||
import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
|
import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
|
||||||
import org.schabi.newpipe.report.ErrorActivity;
|
import org.schabi.newpipe.report.ErrorActivity;
|
||||||
|
@ -921,7 +920,7 @@ public class VideoDetailFragment
|
||||||
.getBoolean(this.getString(R.string.use_external_video_player_key), false)) {
|
.getBoolean(this.getString(R.string.use_external_video_player_key), false)) {
|
||||||
startOnExternalPlayer(activity, currentInfo, selectedVideoStream);
|
startOnExternalPlayer(activity, currentInfo, selectedVideoStream);
|
||||||
} else {
|
} else {
|
||||||
openNormalPlayer(selectedVideoStream);
|
openNormalPlayer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -934,24 +933,13 @@ public class VideoDetailFragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openNormalPlayer(VideoStream selectedVideoStream) {
|
private void openNormalPlayer() {
|
||||||
Intent mIntent;
|
Intent mIntent;
|
||||||
boolean useOldPlayer = PlayerHelper.isUsingOldPlayer(activity) || (Build.VERSION.SDK_INT < 16);
|
final PlayQueue playQueue = new SinglePlayQueue(currentInfo);
|
||||||
if (!useOldPlayer) {
|
mIntent = NavigationHelper.getPlayerIntent(activity,
|
||||||
// ExoPlayer
|
MainVideoPlayer.class,
|
||||||
final PlayQueue playQueue = new SinglePlayQueue(currentInfo);
|
playQueue,
|
||||||
mIntent = NavigationHelper.getPlayerIntent(activity,
|
getSelectedVideoStream().getResolution());
|
||||||
MainVideoPlayer.class,
|
|
||||||
playQueue,
|
|
||||||
getSelectedVideoStream().getResolution());
|
|
||||||
} else {
|
|
||||||
// Internal Player
|
|
||||||
mIntent = new Intent(activity, PlayVideoActivity.class)
|
|
||||||
.putExtra(PlayVideoActivity.VIDEO_TITLE, currentInfo.getName())
|
|
||||||
.putExtra(PlayVideoActivity.STREAM_URL, selectedVideoStream.getUrl())
|
|
||||||
.putExtra(PlayVideoActivity.VIDEO_URL, currentInfo.getUrl())
|
|
||||||
.putExtra(PlayVideoActivity.START_POSITION, currentInfo.getStartPosition());
|
|
||||||
}
|
|
||||||
startActivity(mIntent);
|
startActivity(mIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,35 +98,54 @@ public abstract class BasePlayer implements
|
||||||
Player.EventListener, PlaybackListener, ImageLoadingListener {
|
Player.EventListener, PlaybackListener, ImageLoadingListener {
|
||||||
|
|
||||||
public static final boolean DEBUG = !BuildConfig.BUILD_TYPE.equals("release");
|
public static final boolean DEBUG = !BuildConfig.BUILD_TYPE.equals("release");
|
||||||
@NonNull public static final String TAG = "BasePlayer";
|
@NonNull
|
||||||
|
public static final String TAG = "BasePlayer";
|
||||||
|
|
||||||
@NonNull final protected Context context;
|
@NonNull
|
||||||
|
final protected Context context;
|
||||||
|
|
||||||
@NonNull final protected BroadcastReceiver broadcastReceiver;
|
@NonNull
|
||||||
@NonNull final protected IntentFilter intentFilter;
|
final protected BroadcastReceiver broadcastReceiver;
|
||||||
|
@NonNull
|
||||||
|
final protected IntentFilter intentFilter;
|
||||||
|
|
||||||
@NonNull final protected HistoryRecordManager recordManager;
|
@NonNull
|
||||||
|
final protected HistoryRecordManager recordManager;
|
||||||
|
|
||||||
@NonNull final protected CustomTrackSelector trackSelector;
|
@NonNull
|
||||||
@NonNull final protected PlayerDataSource dataSource;
|
final protected CustomTrackSelector trackSelector;
|
||||||
|
@NonNull
|
||||||
|
final protected PlayerDataSource dataSource;
|
||||||
|
|
||||||
@NonNull final private LoadControl loadControl;
|
@NonNull
|
||||||
@NonNull final private RenderersFactory renderFactory;
|
final private LoadControl loadControl;
|
||||||
|
@NonNull
|
||||||
|
final private RenderersFactory renderFactory;
|
||||||
|
|
||||||
@NonNull final private SerialDisposable progressUpdateReactor;
|
@NonNull
|
||||||
@NonNull final private CompositeDisposable databaseUpdateReactor;
|
final private SerialDisposable progressUpdateReactor;
|
||||||
|
@NonNull
|
||||||
|
final private CompositeDisposable databaseUpdateReactor;
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// Intent
|
// Intent
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
@NonNull public static final String REPEAT_MODE = "repeat_mode";
|
@NonNull
|
||||||
@NonNull public static final String PLAYBACK_PITCH = "playback_pitch";
|
public static final String REPEAT_MODE = "repeat_mode";
|
||||||
@NonNull public static final String PLAYBACK_SPEED = "playback_speed";
|
@NonNull
|
||||||
@NonNull public static final String PLAYBACK_SKIP_SILENCE = "playback_skip_silence";
|
public static final String PLAYBACK_PITCH = "playback_pitch";
|
||||||
@NonNull public static final String PLAYBACK_QUALITY = "playback_quality";
|
@NonNull
|
||||||
@NonNull public static final String PLAY_QUEUE_KEY = "play_queue_key";
|
public static final String PLAYBACK_SPEED = "playback_speed";
|
||||||
@NonNull public static final String APPEND_ONLY = "append_only";
|
@NonNull
|
||||||
@NonNull public static final String SELECT_ON_APPEND = "select_on_append";
|
public static final String PLAYBACK_SKIP_SILENCE = "playback_skip_silence";
|
||||||
|
@NonNull
|
||||||
|
public static final String PLAYBACK_QUALITY = "playback_quality";
|
||||||
|
@NonNull
|
||||||
|
public static final String PLAY_QUEUE_KEY = "play_queue_key";
|
||||||
|
@NonNull
|
||||||
|
public static final String APPEND_ONLY = "append_only";
|
||||||
|
@NonNull
|
||||||
|
public static final String SELECT_ON_APPEND = "select_on_append";
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// Playback
|
// Playback
|
||||||
|
@ -137,13 +156,18 @@ public abstract class BasePlayer implements
|
||||||
protected PlayQueue playQueue;
|
protected PlayQueue playQueue;
|
||||||
protected PlayQueueAdapter playQueueAdapter;
|
protected PlayQueueAdapter playQueueAdapter;
|
||||||
|
|
||||||
@Nullable protected MediaSourceManager playbackManager;
|
@Nullable
|
||||||
|
protected MediaSourceManager playbackManager;
|
||||||
|
|
||||||
@Nullable private PlayQueueItem currentItem;
|
@Nullable
|
||||||
@Nullable private MediaSourceTag currentMetadata;
|
private PlayQueueItem currentItem;
|
||||||
@Nullable private Bitmap currentThumbnail;
|
@Nullable
|
||||||
|
private MediaSourceTag currentMetadata;
|
||||||
|
@Nullable
|
||||||
|
private Bitmap currentThumbnail;
|
||||||
|
|
||||||
@Nullable protected Toast errorToast;
|
@Nullable
|
||||||
|
protected Toast errorToast;
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// Player
|
// Player
|
||||||
|
@ -213,7 +237,8 @@ public abstract class BasePlayer implements
|
||||||
registerBroadcastReceiver();
|
registerBroadcastReceiver();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initListeners() {}
|
public void initListeners() {
|
||||||
|
}
|
||||||
|
|
||||||
public void handleIntent(Intent intent) {
|
public void handleIntent(Intent intent) {
|
||||||
if (DEBUG) Log.d(TAG, "handleIntent() called with: intent = [" + intent + "]");
|
if (DEBUG) Log.d(TAG, "handleIntent() called with: intent = [" + intent + "]");
|
||||||
|
@ -297,7 +322,6 @@ public abstract class BasePlayer implements
|
||||||
databaseUpdateReactor.clear();
|
databaseUpdateReactor.clear();
|
||||||
progressUpdateReactor.set(null);
|
progressUpdateReactor.set(null);
|
||||||
|
|
||||||
simpleExoPlayer = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -425,13 +449,15 @@ public abstract class BasePlayer implements
|
||||||
if (!isProgressLoopRunning()) startProgressLoop();
|
if (!isProgressLoopRunning()) startProgressLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onBuffering() {}
|
public void onBuffering() {
|
||||||
|
}
|
||||||
|
|
||||||
public void onPaused() {
|
public void onPaused() {
|
||||||
if (isProgressLoopRunning()) stopProgressLoop();
|
if (isProgressLoopRunning()) stopProgressLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPausedSeek() {}
|
public void onPausedSeek() {
|
||||||
|
}
|
||||||
|
|
||||||
public void onCompleted() {
|
public void onCompleted() {
|
||||||
if (DEBUG) Log.d(TAG, "onCompleted() called");
|
if (DEBUG) Log.d(TAG, "onCompleted() called");
|
||||||
|
@ -602,19 +628,19 @@ public abstract class BasePlayer implements
|
||||||
/**
|
/**
|
||||||
* Processes the exceptions produced by {@link com.google.android.exoplayer2.ExoPlayer ExoPlayer}.
|
* Processes the exceptions produced by {@link com.google.android.exoplayer2.ExoPlayer ExoPlayer}.
|
||||||
* There are multiple types of errors: <br><br>
|
* There are multiple types of errors: <br><br>
|
||||||
*
|
* <p>
|
||||||
* {@link ExoPlaybackException#TYPE_SOURCE TYPE_SOURCE}: <br><br>
|
* {@link ExoPlaybackException#TYPE_SOURCE TYPE_SOURCE}: <br><br>
|
||||||
*
|
* <p>
|
||||||
* {@link ExoPlaybackException#TYPE_UNEXPECTED TYPE_UNEXPECTED}: <br><br>
|
* {@link ExoPlaybackException#TYPE_UNEXPECTED TYPE_UNEXPECTED}: <br><br>
|
||||||
* If a runtime error occurred, then we can try to recover it by restarting the playback
|
* If a runtime error occurred, then we can try to recover it by restarting the playback
|
||||||
* after setting the timestamp recovery. <br><br>
|
* after setting the timestamp recovery. <br><br>
|
||||||
*
|
* <p>
|
||||||
* {@link ExoPlaybackException#TYPE_RENDERER TYPE_RENDERER}: <br><br>
|
* {@link ExoPlaybackException#TYPE_RENDERER TYPE_RENDERER}: <br><br>
|
||||||
* If the renderer failed, treat the error as unrecoverable.
|
* If the renderer failed, treat the error as unrecoverable.
|
||||||
*
|
*
|
||||||
* @see #processSourceError(IOException)
|
* @see #processSourceError(IOException)
|
||||||
* @see Player.EventListener#onPlayerError(ExoPlaybackException)
|
* @see Player.EventListener#onPlayerError(ExoPlaybackException)
|
||||||
* */
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerError(ExoPlaybackException error) {
|
public void onPlayerError(ExoPlaybackException error) {
|
||||||
if (DEBUG) Log.d(TAG, "ExoPlayer - onPlayerError() called with: " +
|
if (DEBUG) Log.d(TAG, "ExoPlayer - onPlayerError() called with: " +
|
||||||
|
@ -900,8 +926,8 @@ public abstract class BasePlayer implements
|
||||||
if (DEBUG) Log.d(TAG, "onPlayPrevious() called");
|
if (DEBUG) Log.d(TAG, "onPlayPrevious() called");
|
||||||
|
|
||||||
/* If current playback has run for PLAY_PREV_ACTIVATION_LIMIT_MILLIS milliseconds,
|
/* If current playback has run for PLAY_PREV_ACTIVATION_LIMIT_MILLIS milliseconds,
|
||||||
* restart current track. Also restart the track if the current track
|
* restart current track. Also restart the track if the current track
|
||||||
* is the first in a queue.*/
|
* is the first in a queue.*/
|
||||||
if (simpleExoPlayer.getCurrentPosition() > PLAY_PREV_ACTIVATION_LIMIT_MILLIS ||
|
if (simpleExoPlayer.getCurrentPosition() > PLAY_PREV_ACTIVATION_LIMIT_MILLIS ||
|
||||||
playQueue.getIndex() == 0) {
|
playQueue.getIndex() == 0) {
|
||||||
seekToDefault();
|
seekToDefault();
|
||||||
|
@ -1010,8 +1036,8 @@ public abstract class BasePlayer implements
|
||||||
try {
|
try {
|
||||||
metadata = (MediaSourceTag) simpleExoPlayer.getCurrentTag();
|
metadata = (MediaSourceTag) simpleExoPlayer.getCurrentTag();
|
||||||
} catch (IndexOutOfBoundsException | ClassCastException error) {
|
} catch (IndexOutOfBoundsException | ClassCastException error) {
|
||||||
if(DEBUG) Log.d(TAG, "Could not update metadata: " + error.getMessage());
|
if (DEBUG) Log.d(TAG, "Could not update metadata: " + error.getMessage());
|
||||||
if(DEBUG) error.printStackTrace();
|
if (DEBUG) error.printStackTrace();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1075,7 +1101,9 @@ public abstract class BasePlayer implements
|
||||||
currentThumbnail;
|
currentThumbnail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Checks if the current playback is a livestream AND is playing at or beyond the live edge */
|
/**
|
||||||
|
* Checks if the current playback is a livestream AND is playing at or beyond the live edge
|
||||||
|
*/
|
||||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||||
public boolean isLiveEdge() {
|
public boolean isLiveEdge() {
|
||||||
if (simpleExoPlayer == null || !isLive()) return false;
|
if (simpleExoPlayer == null || !isLive()) return false;
|
||||||
|
@ -1099,8 +1127,8 @@ public abstract class BasePlayer implements
|
||||||
} catch (@NonNull IndexOutOfBoundsException ignored) {
|
} catch (@NonNull IndexOutOfBoundsException ignored) {
|
||||||
// Why would this even happen =(
|
// Why would this even happen =(
|
||||||
// But lets log it anyway. Save is save
|
// But lets log it anyway. Save is save
|
||||||
if(DEBUG) Log.d(TAG, "Could not update metadata: " + ignored.getMessage());
|
if (DEBUG) Log.d(TAG, "Could not update metadata: " + ignored.getMessage());
|
||||||
if(DEBUG) ignored.printStackTrace();
|
if (DEBUG) ignored.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,6 @@ import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||||
import org.schabi.newpipe.player.event.PlayerEventListener;
|
import org.schabi.newpipe.player.event.PlayerEventListener;
|
||||||
import org.schabi.newpipe.player.helper.LockManager;
|
import org.schabi.newpipe.player.helper.LockManager;
|
||||||
import org.schabi.newpipe.player.helper.PlayerHelper;
|
import org.schabi.newpipe.player.helper.PlayerHelper;
|
||||||
import org.schabi.newpipe.player.old.PlayVideoActivity;
|
|
||||||
import org.schabi.newpipe.player.resolver.MediaSourceTag;
|
import org.schabi.newpipe.player.resolver.MediaSourceTag;
|
||||||
import org.schabi.newpipe.player.resolver.VideoPlaybackResolver;
|
import org.schabi.newpipe.player.resolver.VideoPlaybackResolver;
|
||||||
import org.schabi.newpipe.util.ListHelper;
|
import org.schabi.newpipe.util.ListHelper;
|
||||||
|
@ -80,7 +79,6 @@ import java.util.List;
|
||||||
import static org.schabi.newpipe.player.BasePlayer.STATE_PLAYING;
|
import static org.schabi.newpipe.player.BasePlayer.STATE_PLAYING;
|
||||||
import static org.schabi.newpipe.player.VideoPlayer.DEFAULT_CONTROLS_DURATION;
|
import static org.schabi.newpipe.player.VideoPlayer.DEFAULT_CONTROLS_DURATION;
|
||||||
import static org.schabi.newpipe.player.VideoPlayer.DEFAULT_CONTROLS_HIDE_TIME;
|
import static org.schabi.newpipe.player.VideoPlayer.DEFAULT_CONTROLS_HIDE_TIME;
|
||||||
import static org.schabi.newpipe.player.helper.PlayerHelper.isUsingOldPlayer;
|
|
||||||
import static org.schabi.newpipe.util.AnimationUtils.animateView;
|
import static org.schabi.newpipe.util.AnimationUtils.animateView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -554,27 +552,17 @@ public final class PopupVideoPlayer extends Service {
|
||||||
if (DEBUG) Log.d(TAG, "onFullScreenButtonClicked() called");
|
if (DEBUG) Log.d(TAG, "onFullScreenButtonClicked() called");
|
||||||
|
|
||||||
setRecovery();
|
setRecovery();
|
||||||
Intent intent;
|
final Intent intent = NavigationHelper.getPlayerIntent(
|
||||||
if (!isUsingOldPlayer(getApplicationContext())) {
|
context,
|
||||||
intent = NavigationHelper.getPlayerIntent(
|
MainVideoPlayer.class,
|
||||||
context,
|
this.getPlayQueue(),
|
||||||
MainVideoPlayer.class,
|
this.getRepeatMode(),
|
||||||
this.getPlayQueue(),
|
this.getPlaybackSpeed(),
|
||||||
this.getRepeatMode(),
|
this.getPlaybackPitch(),
|
||||||
this.getPlaybackSpeed(),
|
this.getPlaybackSkipSilence(),
|
||||||
this.getPlaybackPitch(),
|
this.getPlaybackQuality()
|
||||||
this.getPlaybackSkipSilence(),
|
);
|
||||||
this.getPlaybackQuality()
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
);
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
} else {
|
|
||||||
intent = new Intent(PopupVideoPlayer.this, PlayVideoActivity.class)
|
|
||||||
.putExtra(PlayVideoActivity.VIDEO_TITLE, getVideoTitle())
|
|
||||||
.putExtra(PlayVideoActivity.STREAM_URL, getSelectedVideoStream().getUrl())
|
|
||||||
.putExtra(PlayVideoActivity.VIDEO_URL, getVideoUrl())
|
|
||||||
.putExtra(PlayVideoActivity.START_POSITION, Math.round(getPlayer().getCurrentPosition() / 1000f));
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
}
|
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
closePopup();
|
closePopup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,10 +177,6 @@ public class PlayerHelper {
|
||||||
return isBrightnessGestureEnabled(context, true);
|
return isBrightnessGestureEnabled(context, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isUsingOldPlayer(@NonNull final Context context) {
|
|
||||||
return isUsingOldPlayer(context, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isRememberingPopupDimensions(@NonNull final Context context) {
|
public static boolean isRememberingPopupDimensions(@NonNull final Context context) {
|
||||||
return isRememberingPopupDimensions(context, true);
|
return isRememberingPopupDimensions(context, true);
|
||||||
}
|
}
|
||||||
|
@ -318,10 +314,6 @@ public class PlayerHelper {
|
||||||
return getPreferences(context).getBoolean(context.getString(R.string.brightness_gesture_control_key), b);
|
return getPreferences(context).getBoolean(context.getString(R.string.brightness_gesture_control_key), b);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isUsingOldPlayer(@NonNull final Context context, final boolean b) {
|
|
||||||
return getPreferences(context).getBoolean(context.getString(R.string.use_old_player_key), b);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isRememberingPopupDimensions(@NonNull final Context context, final boolean b) {
|
private static boolean isRememberingPopupDimensions(@NonNull final Context context, final boolean b) {
|
||||||
return getPreferences(context).getBoolean(context.getString(R.string.popup_remember_size_pos_key), b);
|
return getPreferences(context).getBoolean(context.getString(R.string.popup_remember_size_pos_key), b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,369 +0,0 @@
|
||||||
package org.schabi.newpipe.player.old;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.pm.ActivityInfo;
|
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.media.AudioManager;
|
|
||||||
import android.media.MediaPlayer;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Display;
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.MediaController;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.VideoView;
|
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) Christian Schabesberger 2015 <chris.schabesberger@mailbox.org>
|
|
||||||
* PlayVideoActivity.java is part of NewPipe.
|
|
||||||
*
|
|
||||||
* NewPipe is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* NewPipe is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class PlayVideoActivity extends AppCompatActivity {
|
|
||||||
|
|
||||||
//// TODO: 11.09.15 add "choose stream" menu
|
|
||||||
|
|
||||||
private static final String TAG = PlayVideoActivity.class.toString();
|
|
||||||
public static final String VIDEO_URL = "video_url";
|
|
||||||
public static final String STREAM_URL = "stream_url";
|
|
||||||
public static final String VIDEO_TITLE = "video_title";
|
|
||||||
private static final String POSITION = "position";
|
|
||||||
public static final String START_POSITION = "start_position";
|
|
||||||
|
|
||||||
private static final long HIDING_DELAY = 3000;
|
|
||||||
|
|
||||||
private String videoUrl = "";
|
|
||||||
|
|
||||||
private ActionBar actionBar;
|
|
||||||
private VideoView videoView;
|
|
||||||
private int position;
|
|
||||||
private MediaController mediaController;
|
|
||||||
private ProgressBar progressBar;
|
|
||||||
private View decorView;
|
|
||||||
private boolean uiIsHidden;
|
|
||||||
private static long lastUiShowTime;
|
|
||||||
private boolean isLandscape = true;
|
|
||||||
private boolean hasSoftKeys;
|
|
||||||
|
|
||||||
private SharedPreferences prefs;
|
|
||||||
private static final String PREF_IS_LANDSCAPE = "is_landscape";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
setContentView(R.layout.activity_play_video);
|
|
||||||
setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
|
||||||
|
|
||||||
//set background arrow style
|
|
||||||
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_arrow_back_white_24dp);
|
|
||||||
|
|
||||||
isLandscape = checkIfLandscape();
|
|
||||||
hasSoftKeys = checkIfHasSoftKeys();
|
|
||||||
|
|
||||||
actionBar = getSupportActionBar();
|
|
||||||
assert actionBar != null;
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
||||||
Intent intent = getIntent();
|
|
||||||
if(mediaController == null) {
|
|
||||||
//prevents back button hiding media controller controls (after showing them)
|
|
||||||
//instead of exiting video
|
|
||||||
//see http://stackoverflow.com/questions/6051825
|
|
||||||
//also solves https://github.com/theScrabi/NewPipe/issues/99
|
|
||||||
mediaController = new MediaController(this) {
|
|
||||||
@Override
|
|
||||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
|
||||||
int keyCode = event.getKeyCode();
|
|
||||||
final boolean uniqueDown = event.getRepeatCount() == 0
|
|
||||||
&& event.getAction() == KeyEvent.ACTION_DOWN;
|
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
|
||||||
if (uniqueDown)
|
|
||||||
{
|
|
||||||
if (isShowing()) {
|
|
||||||
finish();
|
|
||||||
} else {
|
|
||||||
hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return super.dispatchKeyEvent(event);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
position = intent.getIntExtra(START_POSITION, 0)*1000;//convert from seconds to milliseconds
|
|
||||||
|
|
||||||
videoView = findViewById(R.id.video_view);
|
|
||||||
progressBar = findViewById(R.id.play_video_progress_bar);
|
|
||||||
try {
|
|
||||||
videoView.setMediaController(mediaController);
|
|
||||||
videoView.setVideoURI(Uri.parse(intent.getStringExtra(STREAM_URL)));
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
videoView.requestFocus();
|
|
||||||
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
|
|
||||||
@Override
|
|
||||||
public void onPrepared(MediaPlayer mp) {
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
videoView.seekTo(position);
|
|
||||||
if (position <= 0) {
|
|
||||||
videoView.start();
|
|
||||||
showUi();
|
|
||||||
} else {
|
|
||||||
videoView.pause();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
videoUrl = intent.getStringExtra(VIDEO_URL);
|
|
||||||
|
|
||||||
Button button = findViewById(R.id.content_button);
|
|
||||||
button.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if(uiIsHidden) {
|
|
||||||
showUi();
|
|
||||||
} else {
|
|
||||||
hideUi();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
decorView = getWindow().getDecorView();
|
|
||||||
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onSystemUiVisibilityChange(int visibility) {
|
|
||||||
if (visibility == View.VISIBLE && uiIsHidden) {
|
|
||||||
showUi();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 17) {
|
|
||||||
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
|
||||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
|
||||||
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
prefs = getPreferences(Context.MODE_PRIVATE);
|
|
||||||
if(prefs.getBoolean(PREF_IS_LANDSCAPE, false) && !isLandscape) {
|
|
||||||
toggleOrientation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreatePanelMenu(int featured, Menu menu) {
|
|
||||||
super.onCreatePanelMenu(featured, menu);
|
|
||||||
MenuInflater inflater = getMenuInflater();
|
|
||||||
inflater.inflate(R.menu.video_player, menu);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
videoView.pause();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
prefs = getPreferences(Context.MODE_PRIVATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
int id = item.getItemId();
|
|
||||||
switch(id) {
|
|
||||||
case android.R.id.home:
|
|
||||||
finish();
|
|
||||||
break;
|
|
||||||
case R.id.menu_item_share:
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.setAction(Intent.ACTION_SEND);
|
|
||||||
intent.putExtra(Intent.EXTRA_TEXT, videoUrl);
|
|
||||||
intent.setType("text/plain");
|
|
||||||
startActivity(Intent.createChooser(intent, getString(R.string.share_dialog_title)));
|
|
||||||
break;
|
|
||||||
case R.id.menu_item_screen_rotation:
|
|
||||||
toggleOrientation();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Log.e(TAG, "Error: MenuItem not known");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onConfigurationChanged(Configuration config) {
|
|
||||||
super.onConfigurationChanged(config);
|
|
||||||
|
|
||||||
if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
|
||||||
isLandscape = true;
|
|
||||||
adjustMediaControlMetrics();
|
|
||||||
} else if (config.orientation == Configuration.ORIENTATION_PORTRAIT){
|
|
||||||
isLandscape = false;
|
|
||||||
adjustMediaControlMetrics();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSaveInstanceState(Bundle savedInstanceState) {
|
|
||||||
super.onSaveInstanceState(savedInstanceState);
|
|
||||||
//savedInstanceState.putInt(POSITION, videoView.getCurrentPosition());
|
|
||||||
//videoView.pause();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRestoreInstanceState(Bundle savedInstanceState) {
|
|
||||||
super.onRestoreInstanceState(savedInstanceState);
|
|
||||||
position = savedInstanceState.getInt(POSITION);
|
|
||||||
//videoView.seekTo(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showUi() {
|
|
||||||
try {
|
|
||||||
uiIsHidden = false;
|
|
||||||
mediaController.show(100000);
|
|
||||||
actionBar.show();
|
|
||||||
adjustMediaControlMetrics();
|
|
||||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
||||||
Handler handler = new Handler();
|
|
||||||
handler.postDelayed(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if ((System.currentTimeMillis() - lastUiShowTime) >= HIDING_DELAY) {
|
|
||||||
hideUi();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, HIDING_DELAY);
|
|
||||||
lastUiShowTime = System.currentTimeMillis();
|
|
||||||
}catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void hideUi() {
|
|
||||||
uiIsHidden = true;
|
|
||||||
actionBar.hide();
|
|
||||||
mediaController.hide();
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 17) {
|
|
||||||
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
|
||||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
|
||||||
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
|
||||||
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
|
||||||
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
|
|
||||||
}
|
|
||||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
|
||||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void adjustMediaControlMetrics() {
|
|
||||||
MediaController.LayoutParams mediaControllerLayout
|
|
||||||
= new MediaController.LayoutParams(MediaController.LayoutParams.MATCH_PARENT,
|
|
||||||
MediaController.LayoutParams.WRAP_CONTENT);
|
|
||||||
|
|
||||||
if(!hasSoftKeys) {
|
|
||||||
mediaControllerLayout.setMargins(20, 0, 20, 20);
|
|
||||||
} else {
|
|
||||||
int width = getNavigationBarWidth();
|
|
||||||
int height = getNavigationBarHeight();
|
|
||||||
mediaControllerLayout.setMargins(width + 20, 0, width + 20, height + 20);
|
|
||||||
}
|
|
||||||
mediaController.setLayoutParams(mediaControllerLayout);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean checkIfHasSoftKeys(){
|
|
||||||
return Build.VERSION.SDK_INT >= 17 ||
|
|
||||||
getNavigationBarHeight() != 0 ||
|
|
||||||
getNavigationBarWidth() != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getNavigationBarHeight() {
|
|
||||||
if(Build.VERSION.SDK_INT >= 17) {
|
|
||||||
Display d = getWindowManager().getDefaultDisplay();
|
|
||||||
|
|
||||||
DisplayMetrics realDisplayMetrics = new DisplayMetrics();
|
|
||||||
d.getRealMetrics(realDisplayMetrics);
|
|
||||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
|
||||||
d.getMetrics(displayMetrics);
|
|
||||||
|
|
||||||
int realHeight = realDisplayMetrics.heightPixels;
|
|
||||||
int displayHeight = displayMetrics.heightPixels;
|
|
||||||
return realHeight - displayHeight;
|
|
||||||
} else {
|
|
||||||
return 50;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getNavigationBarWidth() {
|
|
||||||
if(Build.VERSION.SDK_INT >= 17) {
|
|
||||||
Display d = getWindowManager().getDefaultDisplay();
|
|
||||||
|
|
||||||
DisplayMetrics realDisplayMetrics = new DisplayMetrics();
|
|
||||||
d.getRealMetrics(realDisplayMetrics);
|
|
||||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
|
||||||
d.getMetrics(displayMetrics);
|
|
||||||
|
|
||||||
int realWidth = realDisplayMetrics.widthPixels;
|
|
||||||
int displayWidth = displayMetrics.widthPixels;
|
|
||||||
return realWidth - displayWidth;
|
|
||||||
} else {
|
|
||||||
return 50;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean checkIfLandscape() {
|
|
||||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
|
||||||
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
|
||||||
return displayMetrics.heightPixels < displayMetrics.widthPixels;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void toggleOrientation() {
|
|
||||||
if(isLandscape) {
|
|
||||||
isLandscape = false;
|
|
||||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
|
||||||
} else {
|
|
||||||
isLandscape = true;
|
|
||||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
|
|
||||||
}
|
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
|
||||||
editor.putBoolean(PREF_IS_LANDSCAPE, isLandscape);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -110,7 +110,8 @@ public final class ListHelper {
|
||||||
: context.getString(R.string.best_resolution_key);
|
: context.getString(R.string.best_resolution_key);
|
||||||
|
|
||||||
String maxResolution = getResolutionLimit(context);
|
String maxResolution = getResolutionLimit(context);
|
||||||
if (maxResolution != null && compareVideoStreamResolution(maxResolution, resolution) < 1){
|
if (maxResolution != null && (resolution.equals(context.getString(R.string.best_resolution_key))
|
||||||
|
|| compareVideoStreamResolution(maxResolution, resolution) < 1)) {
|
||||||
resolution = maxResolution;
|
resolution = maxResolution;
|
||||||
}
|
}
|
||||||
return resolution;
|
return resolution;
|
||||||
|
|
|
@ -49,7 +49,6 @@ import org.schabi.newpipe.player.MainVideoPlayer;
|
||||||
import org.schabi.newpipe.player.PopupVideoPlayer;
|
import org.schabi.newpipe.player.PopupVideoPlayer;
|
||||||
import org.schabi.newpipe.player.PopupVideoPlayerActivity;
|
import org.schabi.newpipe.player.PopupVideoPlayerActivity;
|
||||||
import org.schabi.newpipe.player.VideoPlayer;
|
import org.schabi.newpipe.player.VideoPlayer;
|
||||||
import org.schabi.newpipe.player.old.PlayVideoActivity;
|
|
||||||
import org.schabi.newpipe.player.playqueue.PlayQueue;
|
import org.schabi.newpipe.player.playqueue.PlayQueue;
|
||||||
import org.schabi.newpipe.settings.SettingsActivity;
|
import org.schabi.newpipe.settings.SettingsActivity;
|
||||||
|
|
||||||
|
@ -117,26 +116,6 @@ public class NavigationHelper {
|
||||||
context.startActivity(playerIntent);
|
context.startActivity(playerIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void playOnOldVideoPlayer(Context context, StreamInfo info) {
|
|
||||||
ArrayList<VideoStream> videoStreamsList = new ArrayList<>(ListHelper.getSortedStreamVideosList(context, info.getVideoStreams(), null, false));
|
|
||||||
int index = ListHelper.getDefaultResolutionIndex(context, videoStreamsList);
|
|
||||||
|
|
||||||
if (index == -1) {
|
|
||||||
Toast.makeText(context, R.string.video_streams_empty, Toast.LENGTH_SHORT).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
VideoStream videoStream = videoStreamsList.get(index);
|
|
||||||
Intent intent = new Intent(context, PlayVideoActivity.class)
|
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
||||||
.putExtra(PlayVideoActivity.VIDEO_TITLE, info.getName())
|
|
||||||
.putExtra(PlayVideoActivity.STREAM_URL, videoStream.getUrl())
|
|
||||||
.putExtra(PlayVideoActivity.VIDEO_URL, info.getUrl())
|
|
||||||
.putExtra(PlayVideoActivity.START_POSITION, info.getStartPosition());
|
|
||||||
|
|
||||||
context.startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void playOnPopupPlayer(final Context context, final PlayQueue queue) {
|
public static void playOnPopupPlayer(final Context context, final PlayQueue queue) {
|
||||||
if (!PermissionHelper.isPopupEnabled(context)) {
|
if (!PermissionHelper.isPopupEnabled(context)) {
|
||||||
PermissionHelper.showPopupEnablementToast(context);
|
PermissionHelper.showPopupEnablementToast(context);
|
||||||
|
|
|
@ -96,12 +96,12 @@ public class MissionAdapter extends RecyclerView.Adapter<MissionAdapter.ViewHold
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/*h.itemView.setOnClickListener(new View.OnClickListener() {
|
h.itemView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
showDetail(h);
|
if(h.mission.finished) viewFile(h);
|
||||||
}
|
}
|
||||||
});*/
|
});
|
||||||
|
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
@ -200,14 +200,12 @@ public class MissionAdapter extends RecyclerView.Adapter<MissionAdapter.ViewHold
|
||||||
Menu menu = popup.getMenu();
|
Menu menu = popup.getMenu();
|
||||||
MenuItem start = menu.findItem(R.id.start);
|
MenuItem start = menu.findItem(R.id.start);
|
||||||
MenuItem pause = menu.findItem(R.id.pause);
|
MenuItem pause = menu.findItem(R.id.pause);
|
||||||
MenuItem view = menu.findItem(R.id.view);
|
|
||||||
MenuItem delete = menu.findItem(R.id.delete);
|
MenuItem delete = menu.findItem(R.id.delete);
|
||||||
MenuItem checksum = menu.findItem(R.id.checksum);
|
MenuItem checksum = menu.findItem(R.id.checksum);
|
||||||
|
|
||||||
// Set to false first
|
// Set to false first
|
||||||
start.setVisible(false);
|
start.setVisible(false);
|
||||||
pause.setVisible(false);
|
pause.setVisible(false);
|
||||||
view.setVisible(false);
|
|
||||||
delete.setVisible(false);
|
delete.setVisible(false);
|
||||||
checksum.setVisible(false);
|
checksum.setVisible(false);
|
||||||
|
|
||||||
|
@ -222,7 +220,6 @@ public class MissionAdapter extends RecyclerView.Adapter<MissionAdapter.ViewHold
|
||||||
pause.setVisible(true);
|
pause.setVisible(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
view.setVisible(true);
|
|
||||||
delete.setVisible(true);
|
delete.setVisible(true);
|
||||||
checksum.setVisible(true);
|
checksum.setVisible(true);
|
||||||
}
|
}
|
||||||
|
@ -241,27 +238,6 @@ public class MissionAdapter extends RecyclerView.Adapter<MissionAdapter.ViewHold
|
||||||
mBinder.onMissionRemoved(mItemList.get(h.position));
|
mBinder.onMissionRemoved(mItemList.get(h.position));
|
||||||
h.lastTimeStamp = -1;
|
h.lastTimeStamp = -1;
|
||||||
h.lastDone = -1;
|
h.lastDone = -1;
|
||||||
return true;
|
|
||||||
case R.id.view:
|
|
||||||
File f = new File(h.mission.location, h.mission.name);
|
|
||||||
String ext = Utility.getFileExt(h.mission.name);
|
|
||||||
|
|
||||||
Log.d(TAG, "Viewing file: " + f.getAbsolutePath() + " ext: " + ext);
|
|
||||||
|
|
||||||
if (ext == null) {
|
|
||||||
Log.w(TAG, "Can't view file because it has no extension: " +
|
|
||||||
h.mission.name);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext.substring(1));
|
|
||||||
Log.v(TAG, "Mime: " + mime + " package: " + mContext.getApplicationContext().getPackageName() + ".provider");
|
|
||||||
if (f.exists()) {
|
|
||||||
viewFileWithFileProvider(f, mime);
|
|
||||||
} else {
|
|
||||||
Log.w(TAG, "File doesn't exist");
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
case R.id.delete:
|
case R.id.delete:
|
||||||
mDeleteDownloadManager.add(h.mission);
|
mDeleteDownloadManager.add(h.mission);
|
||||||
|
@ -282,6 +258,28 @@ public class MissionAdapter extends RecyclerView.Adapter<MissionAdapter.ViewHold
|
||||||
popup.show();
|
popup.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean viewFile(ViewHolder h) {
|
||||||
|
File f = new File(h.mission.location, h.mission.name);
|
||||||
|
String ext = Utility.getFileExt(h.mission.name);
|
||||||
|
|
||||||
|
Log.d(TAG, "Viewing file: " + f.getAbsolutePath() + " ext: " + ext);
|
||||||
|
|
||||||
|
if (ext == null) {
|
||||||
|
Log.w(TAG, "Can't view file because it has no extension: " +
|
||||||
|
h.mission.name);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext.substring(1));
|
||||||
|
Log.v(TAG, "Mime: " + mime + " package: " + mContext.getApplicationContext().getPackageName() + ".provider");
|
||||||
|
if (f.exists()) {
|
||||||
|
viewFileWithFileProvider(f, mime);
|
||||||
|
} else {
|
||||||
|
Log.w(TAG, "File doesn't exist");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void viewFileWithFileProvider(File file, String mimetype) {
|
private void viewFileWithFileProvider(File file, String mimetype) {
|
||||||
String ourPackage = mContext.getApplicationContext().getPackageName();
|
String ourPackage = mContext.getApplicationContext().getPackageName();
|
||||||
Uri uri = FileProvider.getUriForFile(mContext, ourPackage + ".provider", file);
|
Uri uri = FileProvider.getUriForFile(mContext, ourPackage + ".provider", file);
|
||||||
|
|
|
@ -7,11 +7,7 @@
|
||||||
<item
|
<item
|
||||||
android:id="@+id/pause"
|
android:id="@+id/pause"
|
||||||
android:title="@string/pause"/>
|
android:title="@string/pause"/>
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/view"
|
|
||||||
android:title="@string/view"/>
|
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/delete"
|
android:id="@+id/delete"
|
||||||
android:title="@string/delete"/>
|
android:title="@string/delete"/>
|
||||||
|
|
|
@ -165,8 +165,6 @@
|
||||||
<string name="audio">الصوت</string>
|
<string name="audio">الصوت</string>
|
||||||
<string name="retry">إعادة المحاولة</string>
|
<string name="retry">إعادة المحاولة</string>
|
||||||
<string name="storage_permission_denied">تم رفض إذن الوصول إلى التخزين</string>
|
<string name="storage_permission_denied">تم رفض إذن الوصول إلى التخزين</string>
|
||||||
<string name="use_old_player_title">استخدام المشغل القديم</string>
|
|
||||||
<string name="use_old_player_summary">المشغل القديم المدمج في إطار Mediaframework</string>
|
|
||||||
|
|
||||||
<string name="short_thousand">ألف</string>
|
<string name="short_thousand">ألف</string>
|
||||||
<string name="short_million">مليون</string>
|
<string name="short_million">مليون</string>
|
||||||
|
|
|
@ -508,4 +508,21 @@
|
||||||
<string name="grid">Сетка</string>
|
<string name="grid">Сетка</string>
|
||||||
<string name="auto">Автоматически</string>
|
<string name="auto">Автоматически</string>
|
||||||
|
|
||||||
|
<string name="brightness_gesture_control_summary">Менять яркость плеера жестом</string>
|
||||||
|
<string name="brightness_gesture_control_title">Жест яркости</string>
|
||||||
|
<string name="download_to_sdcard_error_message">Загрузка на внешний накопитель невозможна. Сбросить расположение папки загрузки?</string>
|
||||||
|
<string name="download_to_sdcard_error_title">Внешний накопитель недоступен</string>
|
||||||
|
<string name="main_page_content_summary">Вкладки, видимые на главной странице</string>
|
||||||
|
<string name="restore_defaults">По умолчанию</string>
|
||||||
|
<string name="restore_defaults_confirmation">Хотите восстановить умолчания?</string>
|
||||||
|
<string name="saved_tabs_invalid_json">Ошибка чтения сохранённых вкладок. Используются вкладки по умолчанию</string>
|
||||||
|
<string name="selection">Выбор</string>
|
||||||
|
<string name="subscribers_count_not_available">Количество подписчиков недоступно</string>
|
||||||
|
<string name="switch_view">Переключить вид</string>
|
||||||
|
<string name="tab_choose">Выберите вкладку</string>
|
||||||
|
<string name="tab_new">Новая вкладка</string>
|
||||||
|
<string name="unsubscribe">Отписаться</string>
|
||||||
|
<string name="volume_gesture_control_summary">Менять громкость плеера жестом</string>
|
||||||
|
<string name="volume_gesture_control_title">Жест громкости</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
<string name="use_external_video_player_key" translatable="false">use_external_video_player</string>
|
<string name="use_external_video_player_key" translatable="false">use_external_video_player</string>
|
||||||
<string name="use_external_audio_player_key" translatable="false">use_external_audio_player</string>
|
<string name="use_external_audio_player_key" translatable="false">use_external_audio_player</string>
|
||||||
<string name="autoplay_through_intent_key" translatable="false">autoplay_through_intent</string>
|
<string name="autoplay_through_intent_key" translatable="false">autoplay_through_intent</string>
|
||||||
<string name="use_old_player_key" translatable="false">use_oldplayer</string>
|
|
||||||
|
|
||||||
<string name="volume_gesture_control_key" translatable="false">volume_gesture_control</string>
|
<string name="volume_gesture_control_key" translatable="false">volume_gesture_control</string>
|
||||||
<string name="brightness_gesture_control_key" translatable="false">brightness_gesture_control</string>
|
<string name="brightness_gesture_control_key" translatable="false">brightness_gesture_control</string>
|
||||||
|
|
|
@ -239,8 +239,6 @@
|
||||||
<string name="audio">Audio</string>
|
<string name="audio">Audio</string>
|
||||||
<string name="retry">Retry</string>
|
<string name="retry">Retry</string>
|
||||||
<string name="storage_permission_denied">Storage access permission denied</string>
|
<string name="storage_permission_denied">Storage access permission denied</string>
|
||||||
<string name="use_old_player_title">Use old player</string>
|
|
||||||
<string name="use_old_player_summary">Old built-in Mediaframework player</string>
|
|
||||||
|
|
||||||
<string name="short_thousand">K</string>
|
<string name="short_thousand">K</string>
|
||||||
<string name="short_million">M</string>
|
<string name="short_million">M</string>
|
||||||
|
|
|
@ -29,12 +29,6 @@
|
||||||
android:summary="@string/show_search_suggestions_summary"
|
android:summary="@string/show_search_suggestions_summary"
|
||||||
android:title="@string/show_search_suggestions_title"/>
|
android:title="@string/show_search_suggestions_title"/>
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:defaultValue="false"
|
|
||||||
android:key="@string/auto_queue_key"
|
|
||||||
android:summary="@string/auto_queue_summary"
|
|
||||||
android:title="@string/auto_queue_title"/>
|
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="@string/download_thumbnail_key"
|
android:key="@string/download_thumbnail_key"
|
||||||
|
|
|
@ -64,12 +64,6 @@
|
||||||
android:key="@string/use_external_audio_player_key"
|
android:key="@string/use_external_audio_player_key"
|
||||||
android:title="@string/use_external_audio_player_title"/>
|
android:title="@string/use_external_audio_player_title"/>
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:defaultValue="false"
|
|
||||||
android:key="@string/use_old_player_key"
|
|
||||||
android:summary="@string/use_old_player_summary"
|
|
||||||
android:title="@string/use_old_player_title"/>
|
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="@string/show_play_with_kodi_key"
|
android:key="@string/show_play_with_kodi_key"
|
||||||
|
@ -98,6 +92,12 @@
|
||||||
android:summary="@string/minimize_on_exit_summary"
|
android:summary="@string/minimize_on_exit_summary"
|
||||||
android:title="@string/minimize_on_exit_title"/>
|
android:title="@string/minimize_on_exit_title"/>
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="@string/auto_queue_key"
|
||||||
|
android:summary="@string/auto_queue_summary"
|
||||||
|
android:title="@string/auto_queue_title"/>
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="@string/resume_on_audio_focus_gain_key"
|
android:key="@string/resume_on_audio_focus_gain_key"
|
||||||
|
|
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 65 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 90 KiB |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 170 KiB After Width: | Height: | Size: 170 KiB |
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 100 KiB |
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |