Changes for review
This commit is contained in:
parent
398cbe9284
commit
a7fbe05a73
22 changed files with 182 additions and 350 deletions
|
@ -38,9 +38,6 @@
|
||||||
<service
|
<service
|
||||||
android:name=".player.BackgroundPlayer"
|
android:name=".player.BackgroundPlayer"
|
||||||
android:exported="false">
|
android:exported="false">
|
||||||
<!--<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MEDIA_BUTTON" />
|
|
||||||
</intent-filter>-->
|
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service
|
<service
|
||||||
|
|
|
@ -456,7 +456,10 @@ public class MainActivity extends AppCompatActivity {
|
||||||
FrameLayout bottomSheetLayout = findViewById(R.id.fragment_player_holder);
|
FrameLayout bottomSheetLayout = findViewById(R.id.fragment_player_holder);
|
||||||
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(bottomSheetLayout);
|
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(bottomSheetLayout);
|
||||||
|
|
||||||
if (bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_HIDDEN || bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_COLLAPSED) {
|
final int sheetState = bottomSheetBehavior.getState();
|
||||||
|
// In case bottomSheet is not visible on the screen or collapsed we can assume that the user interacts with a fragment
|
||||||
|
// inside fragment_holder so all back presses should be handled by it
|
||||||
|
if (sheetState == BottomSheetBehavior.STATE_HIDDEN || sheetState == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||||
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_holder);
|
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_holder);
|
||||||
// If current fragment implements BackPressable (i.e. can/wanna handle back press) delegate the back press to it
|
// If current fragment implements BackPressable (i.e. can/wanna handle back press) delegate the back press to it
|
||||||
if (fragment instanceof BackPressable) {
|
if (fragment instanceof BackPressable) {
|
||||||
|
@ -540,10 +543,6 @@ public class MainActivity extends AppCompatActivity {
|
||||||
super.onCreateOptionsMenu(menu);
|
super.onCreateOptionsMenu(menu);
|
||||||
|
|
||||||
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_holder);
|
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_holder);
|
||||||
if (!(fragment instanceof VideoDetailFragment)) {
|
|
||||||
findViewById(R.id.toolbar).findViewById(R.id.toolbar_spinner).setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(fragment instanceof SearchFragment)) {
|
if (!(fragment instanceof SearchFragment)) {
|
||||||
findViewById(R.id.toolbar).findViewById(R.id.toolbar_search_container).setVisibility(View.GONE);
|
findViewById(R.id.toolbar).findViewById(R.id.toolbar_search_container).setVisibility(View.GONE);
|
||||||
|
|
||||||
|
|
|
@ -606,13 +606,8 @@ public class RouterActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openMainPlayer(PlayQueue playQueue, Choice choice) {
|
private void openMainPlayer(PlayQueue playQueue, Choice choice) {
|
||||||
Intent intent = NavigationHelper.getPlayerIntent(this, MainActivity.class, playQueue, true);
|
NavigationHelper.playOnMainPlayer(this, playQueue, choice.linkType,
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
choice.url, "", true, true);
|
||||||
intent.putExtra(Constants.KEY_LINK_TYPE, choice.linkType);
|
|
||||||
intent.putExtra(Constants.KEY_URL, choice.url);
|
|
||||||
intent.putExtra(Constants.KEY_TITLE, "");
|
|
||||||
intent.putExtra(VideoDetailFragment.AUTO_PLAY, true);
|
|
||||||
this.startActivity(intent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,7 +5,6 @@ import android.app.Activity;
|
||||||
import android.content.*;
|
import android.content.*;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.media.AudioManager;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
@ -102,11 +101,8 @@ public class VideoDetailFragment
|
||||||
PlayerServiceEventListener {
|
PlayerServiceEventListener {
|
||||||
public static final String AUTO_PLAY = "auto_play";
|
public static final String AUTO_PLAY = "auto_play";
|
||||||
|
|
||||||
private int updateFlags = 0;
|
|
||||||
private static final int RELATED_STREAMS_UPDATE_FLAG = 0x1;
|
private static final int RELATED_STREAMS_UPDATE_FLAG = 0x1;
|
||||||
private static final int RESOLUTIONS_MENU_UPDATE_FLAG = 0x2;
|
private static final int COMMENTS_UPDATE_FLAG = 0x2;
|
||||||
private static final int TOOLBAR_ITEMS_UPDATE_FLAG = 0x4;
|
|
||||||
private static final int COMMENTS_UPDATE_FLAG = 0x8;
|
|
||||||
private static final float MAX_OVERLAY_ALPHA = 0.9f;
|
private static final float MAX_OVERLAY_ALPHA = 0.9f;
|
||||||
private static final float MAX_PLAYER_HEIGHT = 0.7f;
|
private static final float MAX_PLAYER_HEIGHT = 0.7f;
|
||||||
|
|
||||||
|
@ -115,10 +111,16 @@ public class VideoDetailFragment
|
||||||
public static final String ACTION_VIDEO_FRAGMENT_RESUMED = "org.schabi.newpipe.VideoDetailFragment.ACTION_VIDEO_FRAGMENT_RESUMED";
|
public static final String ACTION_VIDEO_FRAGMENT_RESUMED = "org.schabi.newpipe.VideoDetailFragment.ACTION_VIDEO_FRAGMENT_RESUMED";
|
||||||
public static final String ACTION_VIDEO_FRAGMENT_STOPPED = "org.schabi.newpipe.VideoDetailFragment.ACTION_VIDEO_FRAGMENT_STOPPED";
|
public static final String ACTION_VIDEO_FRAGMENT_STOPPED = "org.schabi.newpipe.VideoDetailFragment.ACTION_VIDEO_FRAGMENT_STOPPED";
|
||||||
|
|
||||||
|
private static final String COMMENTS_TAB_TAG = "COMMENTS";
|
||||||
|
private static final String RELATED_TAB_TAG = "NEXT VIDEO";
|
||||||
|
private static final String EMPTY_TAB_TAG = "EMPTY TAB";
|
||||||
|
|
||||||
private boolean showRelatedStreams;
|
private boolean showRelatedStreams;
|
||||||
private boolean showComments;
|
private boolean showComments;
|
||||||
private String selectedTabTag;
|
private String selectedTabTag;
|
||||||
|
|
||||||
|
private int updateFlags = 0;
|
||||||
|
|
||||||
@State
|
@State
|
||||||
protected int serviceId = Constants.NO_SERVICE_ID;
|
protected int serviceId = Constants.NO_SERVICE_ID;
|
||||||
@State
|
@State
|
||||||
|
@ -148,10 +150,6 @@ public class VideoDetailFragment
|
||||||
// Views
|
// Views
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
private Menu menu;
|
|
||||||
|
|
||||||
private Spinner spinnerToolbar;
|
|
||||||
|
|
||||||
private LinearLayout contentRootLayoutHiding;
|
private LinearLayout contentRootLayoutHiding;
|
||||||
|
|
||||||
private View thumbnailBackgroundButton;
|
private View thumbnailBackgroundButton;
|
||||||
|
@ -195,10 +193,6 @@ public class VideoDetailFragment
|
||||||
private ImageButton overlayPlayPauseButton;
|
private ImageButton overlayPlayPauseButton;
|
||||||
private ImageButton overlayCloseButton;
|
private ImageButton overlayCloseButton;
|
||||||
|
|
||||||
private static final String COMMENTS_TAB_TAG = "COMMENTS";
|
|
||||||
private static final String RELATED_TAB_TAG = "NEXT VIDEO";
|
|
||||||
private static final String EMPTY_TAB_TAG = "EMPTY TAB";
|
|
||||||
|
|
||||||
private AppBarLayout appBarLayout;
|
private AppBarLayout appBarLayout;
|
||||||
private ViewPager viewPager;
|
private ViewPager viewPager;
|
||||||
private TabAdaptor pageAdapter;
|
private TabAdaptor pageAdapter;
|
||||||
|
@ -207,7 +201,7 @@ public class VideoDetailFragment
|
||||||
|
|
||||||
private ContentObserver settingsContentObserver;
|
private ContentObserver settingsContentObserver;
|
||||||
private ServiceConnection serviceConnection;
|
private ServiceConnection serviceConnection;
|
||||||
private boolean bounded;
|
private boolean bound;
|
||||||
private MainPlayer playerService;
|
private MainPlayer playerService;
|
||||||
private VideoPlayerImpl player;
|
private VideoPlayerImpl player;
|
||||||
|
|
||||||
|
@ -242,12 +236,18 @@ public class VideoDetailFragment
|
||||||
|
|
||||||
if (playerIsNotStopped() && player.videoPlayerSelected()) addVideoPlayerView();
|
if (playerIsNotStopped() && player.videoPlayerSelected()) addVideoPlayerView();
|
||||||
|
|
||||||
// If the video is playing but orientation changed let's make the video in fullscreen again
|
if (isLandscape()) {
|
||||||
if (isLandscape()) checkLandscape();
|
// If the video is playing but orientation changed let's make the video in fullscreen again
|
||||||
else if (player.isInFullscreen()) player.toggleFullscreen();
|
checkLandscape();
|
||||||
|
} else if (player.isFullscreen()) {
|
||||||
|
// Device is in portrait orientation after rotation but UI is in fullscreen.
|
||||||
|
// Return back to non-fullscreen state
|
||||||
|
player.toggleFullscreen();
|
||||||
|
}
|
||||||
|
|
||||||
if (currentInfo != null && isAutoplayEnabled() && player.getParentActivity() == null || playAfterConnect)
|
if (playAfterConnect || (currentInfo != null && isAutoplayEnabled() && player.getParentActivity() == null)) {
|
||||||
openVideoPlayer();
|
openVideoPlayer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -259,15 +259,15 @@ public class VideoDetailFragment
|
||||||
final boolean success = getContext().bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE);
|
final boolean success = getContext().bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE);
|
||||||
|
|
||||||
if (!success) getContext().unbindService(serviceConnection);
|
if (!success) getContext().unbindService(serviceConnection);
|
||||||
bounded = success;
|
bound = success;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unbind() {
|
private void unbind() {
|
||||||
if (DEBUG) Log.d(TAG, "unbind() called");
|
if (DEBUG) Log.d(TAG, "unbind() called");
|
||||||
|
|
||||||
if (bounded) {
|
if (bound) {
|
||||||
getContext().unbindService(serviceConnection);
|
getContext().unbindService(serviceConnection);
|
||||||
bounded = false;
|
bound = false;
|
||||||
stopPlayerListener();
|
stopPlayerListener();
|
||||||
playerService = null;
|
playerService = null;
|
||||||
player = null;
|
player = null;
|
||||||
|
@ -313,9 +313,6 @@ public class VideoDetailFragment
|
||||||
public void
|
public void
|
||||||
onCreate(Bundle savedInstanceState) {
|
onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setHasOptionsMenu(true);
|
|
||||||
|
|
||||||
activity.setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
|
||||||
|
|
||||||
showRelatedStreams = PreferenceManager.getDefaultSharedPreferences(activity)
|
showRelatedStreams = PreferenceManager.getDefaultSharedPreferences(activity)
|
||||||
.getBoolean(getString(R.string.show_next_video_key), true);
|
.getBoolean(getString(R.string.show_next_video_key), true);
|
||||||
|
@ -371,15 +368,9 @@ public class VideoDetailFragment
|
||||||
if (updateFlags != 0) {
|
if (updateFlags != 0) {
|
||||||
if (!isLoading.get() && currentInfo != null) {
|
if (!isLoading.get() && currentInfo != null) {
|
||||||
if ((updateFlags & RELATED_STREAMS_UPDATE_FLAG) != 0) startLoading(false);
|
if ((updateFlags & RELATED_STREAMS_UPDATE_FLAG) != 0) startLoading(false);
|
||||||
if ((updateFlags & RESOLUTIONS_MENU_UPDATE_FLAG) != 0) setupActionBar(currentInfo);
|
|
||||||
if ((updateFlags & COMMENTS_UPDATE_FLAG) != 0) startLoading(false);
|
if ((updateFlags & COMMENTS_UPDATE_FLAG) != 0) startLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((updateFlags & TOOLBAR_ITEMS_UPDATE_FLAG) != 0
|
|
||||||
&& menu != null) {
|
|
||||||
updateMenuItemVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
updateFlags = 0;
|
updateFlags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,14 +409,6 @@ public class VideoDetailFragment
|
||||||
bottomSheetBehavior.setBottomSheetCallback(null);
|
bottomSheetBehavior.setBottomSheetCallback(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroyView() {
|
|
||||||
if (DEBUG) Log.d(TAG, "onDestroyView() called");
|
|
||||||
spinnerToolbar.setOnItemSelectedListener(null);
|
|
||||||
spinnerToolbar.setAdapter(null);
|
|
||||||
super.onDestroyView();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
@ -446,13 +429,6 @@ public class VideoDetailFragment
|
||||||
if (key.equals(getString(R.string.show_next_video_key))) {
|
if (key.equals(getString(R.string.show_next_video_key))) {
|
||||||
showRelatedStreams = sharedPreferences.getBoolean(key, true);
|
showRelatedStreams = sharedPreferences.getBoolean(key, true);
|
||||||
updateFlags |= RELATED_STREAMS_UPDATE_FLAG;
|
updateFlags |= RELATED_STREAMS_UPDATE_FLAG;
|
||||||
} else if (key.equals(getString(R.string.default_video_format_key))
|
|
||||||
|| key.equals(getString(R.string.default_resolution_key))
|
|
||||||
|| key.equals(getString(R.string.show_higher_resolutions_key))
|
|
||||||
|| key.equals(getString(R.string.use_external_video_player_key))) {
|
|
||||||
updateFlags |= RESOLUTIONS_MENU_UPDATE_FLAG;
|
|
||||||
} else if (key.equals(getString(R.string.show_play_with_kodi_key))) {
|
|
||||||
updateFlags |= TOOLBAR_ITEMS_UPDATE_FLAG;
|
|
||||||
} else if (key.equals(getString(R.string.show_comments_key))) {
|
} else if (key.equals(getString(R.string.show_comments_key))) {
|
||||||
showComments = sharedPreferences.getBoolean(key, true);
|
showComments = sharedPreferences.getBoolean(key, true);
|
||||||
updateFlags |= COMMENTS_UPDATE_FLAG;
|
updateFlags |= COMMENTS_UPDATE_FLAG;
|
||||||
|
@ -600,8 +576,6 @@ public class VideoDetailFragment
|
||||||
@Override
|
@Override
|
||||||
protected void initViews(View rootView, Bundle savedInstanceState) {
|
protected void initViews(View rootView, Bundle savedInstanceState) {
|
||||||
super.initViews(rootView, savedInstanceState);
|
super.initViews(rootView, savedInstanceState);
|
||||||
spinnerToolbar = activity.findViewById(R.id.toolbar).findViewById(R.id.toolbar_spinner);
|
|
||||||
|
|
||||||
thumbnailBackgroundButton = rootView.findViewById(R.id.detail_thumbnail_root_layout);
|
thumbnailBackgroundButton = rootView.findViewById(R.id.detail_thumbnail_root_layout);
|
||||||
thumbnailImageView = rootView.findViewById(R.id.detail_thumbnail_image_view);
|
thumbnailImageView = rootView.findViewById(R.id.detail_thumbnail_image_view);
|
||||||
thumbnailPlayButton = rootView.findViewById(R.id.detail_thumbnail_play_button);
|
thumbnailPlayButton = rootView.findViewById(R.id.detail_thumbnail_play_button);
|
||||||
|
@ -730,116 +704,6 @@ public class VideoDetailFragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
|
||||||
// Menu
|
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
||||||
this.menu = menu;
|
|
||||||
|
|
||||||
// CAUTION set item properties programmatically otherwise it would not be accepted by
|
|
||||||
// appcompat itemsinflater.inflate(R.menu.videoitem_detail, menu);
|
|
||||||
|
|
||||||
/*inflater.inflate(R.menu.video_detail_menu, menu);
|
|
||||||
|
|
||||||
updateMenuItemVisibility();
|
|
||||||
|
|
||||||
ActionBar supportActionBar = activity.getSupportActionBar();
|
|
||||||
if (supportActionBar != null) {
|
|
||||||
supportActionBar.setDisplayHomeAsUpEnabled(true);
|
|
||||||
supportActionBar.setDisplayShowTitleEnabled(false);
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateMenuItemVisibility() {
|
|
||||||
/*// show kodi if set in settings
|
|
||||||
menu.findItem(R.id.action_play_with_kodi).setVisible(
|
|
||||||
PreferenceManager.getDefaultSharedPreferences(activity).getBoolean(
|
|
||||||
activity.getString(R.string.show_play_with_kodi_key), false));*/
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
if (isLoading.get()) {
|
|
||||||
// if is still loading block menu
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int id = item.getItemId();
|
|
||||||
switch (id) {
|
|
||||||
case R.id.menu_item_share: {
|
|
||||||
if (currentInfo != null) {
|
|
||||||
ShareUtils.shareUrl(this.getContext(), currentInfo.getName(), currentInfo.getOriginalUrl());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case R.id.menu_item_openInBrowser: {
|
|
||||||
if (currentInfo != null) {
|
|
||||||
ShareUtils.openUrlInBrowser(this.getContext(), currentInfo.getOriginalUrl());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case R.id.action_play_with_kodi:
|
|
||||||
/*try {
|
|
||||||
NavigationHelper.playWithKore(activity, Uri.parse(
|
|
||||||
url.replace("https", "http")));
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (DEBUG) Log.i(TAG, "Failed to start kore", e);
|
|
||||||
showInstallKoreDialog(activity);
|
|
||||||
}*/
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*private static void showInstallKoreDialog(final Context context) {
|
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
|
||||||
builder.setMessage(R.string.kore_not_found)
|
|
||||||
.setPositiveButton(R.string.install, (DialogInterface dialog, int which) ->
|
|
||||||
NavigationHelper.installKore(context))
|
|
||||||
.setNegativeButton(R.string.cancel, (DialogInterface dialog, int which) -> {
|
|
||||||
});
|
|
||||||
builder.create().show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupActionBarOnError(final String url) {
|
|
||||||
if (DEBUG) Log.d(TAG, "setupActionBarHandlerOnError() called with: url = [" + url + "]");
|
|
||||||
Log.e("-----", "missing code");
|
|
||||||
}*/
|
|
||||||
|
|
||||||
private void setupActionBar(final StreamInfo info) {
|
|
||||||
if (DEBUG) Log.d(TAG, "setupActionBarHandler() called with: info = [" + info + "]");
|
|
||||||
boolean isExternalPlayerEnabled = PreferenceManager.getDefaultSharedPreferences(activity)
|
|
||||||
.getBoolean(activity.getString(R.string.use_external_video_player_key), false);
|
|
||||||
|
|
||||||
sortedVideoStreams = ListHelper.getSortedStreamVideosList(
|
|
||||||
activity,
|
|
||||||
info.getVideoStreams(),
|
|
||||||
info.getVideoOnlyStreams(),
|
|
||||||
false);
|
|
||||||
selectedVideoStreamIndex = ListHelper.getDefaultResolutionIndex(activity, sortedVideoStreams);
|
|
||||||
|
|
||||||
/*final StreamItemAdapter<VideoStream, Stream> streamsAdapter =
|
|
||||||
new StreamItemAdapter<>(activity,
|
|
||||||
new StreamSizeWrapper<>(sortedVideoStreams, activity), isExternalPlayerEnabled);
|
|
||||||
|
|
||||||
spinnerToolbar.setAdapter(streamsAdapter);
|
|
||||||
spinnerToolbar.setSelection(selectedVideoStreamIndex);
|
|
||||||
spinnerToolbar.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
|
||||||
selectedVideoStreamIndex = position;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// OwnStack
|
// OwnStack
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
@ -866,7 +730,7 @@ public class VideoDetailFragment
|
||||||
if (DEBUG) Log.d(TAG, "onBackPressed() called");
|
if (DEBUG) Log.d(TAG, "onBackPressed() called");
|
||||||
|
|
||||||
// If we are in fullscreen mode just exit from it via first back press
|
// If we are in fullscreen mode just exit from it via first back press
|
||||||
if (player != null && player.isInFullscreen()) {
|
if (player != null && player.isFullscreen()) {
|
||||||
if (!PlayerHelper.isTablet(activity)) player.onPause();
|
if (!PlayerHelper.isTablet(activity)) player.onPause();
|
||||||
restoreDefaultOrientation();
|
restoreDefaultOrientation();
|
||||||
setAutoplay(false);
|
setAutoplay(false);
|
||||||
|
@ -874,11 +738,10 @@ public class VideoDetailFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have something in history of played items we replay it here
|
// If we have something in history of played items we replay it here
|
||||||
boolean isPreviousCanBePlayed = player != null
|
if (player != null
|
||||||
&& player.getPlayQueue() != null
|
&& player.getPlayQueue() != null
|
||||||
&& player.videoPlayerSelected()
|
&& player.videoPlayerSelected()
|
||||||
&& player.getPlayQueue().previous();
|
&& player.getPlayQueue().previous()) {
|
||||||
if (isPreviousCanBePlayed) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// That means that we are on the start of the stack,
|
// That means that we are on the start of the stack,
|
||||||
|
@ -930,9 +793,8 @@ public class VideoDetailFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectAndLoadVideo(int serviceId, String videoUrl, String name, PlayQueue playQueue) {
|
public void selectAndLoadVideo(int serviceId, String videoUrl, String name, PlayQueue playQueue) {
|
||||||
boolean streamIsTheSame = this.playQueue != null && this.playQueue.equals(playQueue);
|
|
||||||
// Situation when user switches from players to main player. All needed data is here, we can start watching
|
// Situation when user switches from players to main player. All needed data is here, we can start watching
|
||||||
if (streamIsTheSame) {
|
if (this.playQueue != null && this.playQueue.equals(playQueue)) {
|
||||||
openVideoPlayer();
|
openVideoPlayer();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1056,7 +918,7 @@ public class VideoDetailFragment
|
||||||
.getBoolean(activity.getString(R.string.use_external_audio_player_key), false);
|
.getBoolean(activity.getString(R.string.use_external_audio_player_key), false);
|
||||||
|
|
||||||
// If a user watched video inside fullscreen mode and than chose another player return to non-fullscreen mode
|
// If a user watched video inside fullscreen mode and than chose another player return to non-fullscreen mode
|
||||||
if (player != null && player.isInFullscreen()) player.toggleFullscreen();
|
if (player != null && player.isFullscreen()) player.toggleFullscreen();
|
||||||
|
|
||||||
if (!useExternalAudioPlayer && android.os.Build.VERSION.SDK_INT >= 16) {
|
if (!useExternalAudioPlayer && android.os.Build.VERSION.SDK_INT >= 16) {
|
||||||
openNormalBackgroundPlayer(append);
|
openNormalBackgroundPlayer(append);
|
||||||
|
@ -1072,18 +934,16 @@ public class VideoDetailFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
// See UI changes while remote playQueue changes
|
// See UI changes while remote playQueue changes
|
||||||
if (!bounded) startService(false);
|
if (!bound) startService(false);
|
||||||
|
|
||||||
// If a user watched video inside fullscreen mode and than chose another player return to non-fullscreen mode
|
// If a user watched video inside fullscreen mode and than chose another player return to non-fullscreen mode
|
||||||
if (player != null && player.isInFullscreen()) player.toggleFullscreen();
|
if (player != null && player.isFullscreen()) player.toggleFullscreen();
|
||||||
|
|
||||||
PlayQueue queue = setupPlayQueueForIntent(append);
|
PlayQueue queue = setupPlayQueueForIntent(append);
|
||||||
if (append) {
|
if (append) {
|
||||||
NavigationHelper.enqueueOnPopupPlayer(activity, queue, false);
|
NavigationHelper.enqueueOnPopupPlayer(activity, queue, false);
|
||||||
} else {
|
} else {
|
||||||
Runnable onAllow = () -> NavigationHelper.playOnPopupPlayer(activity, queue, true);
|
replaceQueueIfUserConfirms(() -> NavigationHelper.playOnPopupPlayer(activity, queue, true));
|
||||||
if (shouldAskBeforeClearingQueue()) showClearingQueueConfirmation(onAllow);
|
|
||||||
else onAllow.run();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1093,27 +953,23 @@ public class VideoDetailFragment
|
||||||
VideoStream selectedVideoStream = getSelectedVideoStream();
|
VideoStream selectedVideoStream = getSelectedVideoStream();
|
||||||
startOnExternalPlayer(activity, currentInfo, selectedVideoStream);
|
startOnExternalPlayer(activity, currentInfo, selectedVideoStream);
|
||||||
} else {
|
} else {
|
||||||
Runnable onAllow = this::openNormalPlayer;
|
replaceQueueIfUserConfirms(this::openMainPlayer);
|
||||||
if (shouldAskBeforeClearingQueue()) showClearingQueueConfirmation(onAllow);
|
|
||||||
else onAllow.run();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openNormalBackgroundPlayer(final boolean append) {
|
private void openNormalBackgroundPlayer(final boolean append) {
|
||||||
// See UI changes while remote playQueue changes
|
// See UI changes while remote playQueue changes
|
||||||
if (!bounded) startService(false);
|
if (!bound) startService(false);
|
||||||
|
|
||||||
PlayQueue queue = setupPlayQueueForIntent(append);
|
PlayQueue queue = setupPlayQueueForIntent(append);
|
||||||
if (append) {
|
if (append) {
|
||||||
NavigationHelper.enqueueOnBackgroundPlayer(activity, queue, false);
|
NavigationHelper.enqueueOnBackgroundPlayer(activity, queue, false);
|
||||||
} else {
|
} else {
|
||||||
Runnable onAllow = () -> NavigationHelper.playOnBackgroundPlayer(activity, queue, true);
|
replaceQueueIfUserConfirms(() -> NavigationHelper.playOnBackgroundPlayer(activity, queue, true));
|
||||||
if (shouldAskBeforeClearingQueue()) showClearingQueueConfirmation(onAllow);
|
|
||||||
else onAllow.run();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openNormalPlayer() {
|
private void openMainPlayer() {
|
||||||
if (playerService == null) {
|
if (playerService == null) {
|
||||||
startService(true);
|
startService(true);
|
||||||
return;
|
return;
|
||||||
|
@ -1144,7 +1000,7 @@ public class VideoDetailFragment
|
||||||
|
|
||||||
PlayQueue queue = playQueue;
|
PlayQueue queue = playQueue;
|
||||||
// Size can be 0 because queue removes bad stream automatically when error occurs
|
// Size can be 0 because queue removes bad stream automatically when error occurs
|
||||||
if (playQueue == null || playQueue.size() == 0)
|
if (queue == null || queue.size() == 0)
|
||||||
queue = new SinglePlayQueue(currentInfo);
|
queue = new SinglePlayQueue(currentInfo);
|
||||||
|
|
||||||
return queue;
|
return queue;
|
||||||
|
@ -1284,18 +1140,18 @@ public class VideoDetailFragment
|
||||||
boolean isPortrait = metrics.heightPixels > metrics.widthPixels;
|
boolean isPortrait = metrics.heightPixels > metrics.widthPixels;
|
||||||
|
|
||||||
int height;
|
int height;
|
||||||
if (player != null && player.isInFullscreen())
|
if (player != null && player.isFullscreen())
|
||||||
height = isInMultiWindow() ? getView().getHeight() : activity.getWindow().getDecorView().getHeight();
|
height = isInMultiWindow() ? getView().getHeight() : activity.getWindow().getDecorView().getHeight();
|
||||||
else
|
else
|
||||||
height = isPortrait
|
height = isPortrait
|
||||||
? (int) (metrics.widthPixels / (16.0f / 9.0f))
|
? (int) (metrics.widthPixels / (16.0f / 9.0f))
|
||||||
: (int) (metrics.heightPixels / 2f);
|
: (int) (metrics.heightPixels / 2.0f);
|
||||||
|
|
||||||
thumbnailImageView.setLayoutParams(new FrameLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, height));
|
thumbnailImageView.setLayoutParams(new FrameLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, height));
|
||||||
thumbnailImageView.setMinimumHeight(height);
|
thumbnailImageView.setMinimumHeight(height);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
int maxHeight = (int) (metrics.heightPixels * MAX_PLAYER_HEIGHT);
|
int maxHeight = (int) (metrics.heightPixels * MAX_PLAYER_HEIGHT);
|
||||||
player.getSurfaceView().setHeights(height, player.isInFullscreen() ? height : maxHeight);
|
player.getSurfaceView().setHeights(height, player.isFullscreen() ? height : maxHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1353,7 +1209,7 @@ public class VideoDetailFragment
|
||||||
private void restoreDefaultOrientation() {
|
private void restoreDefaultOrientation() {
|
||||||
if (player == null || !player.videoPlayerSelected() || activity == null) return;
|
if (player == null || !player.videoPlayerSelected() || activity == null) return;
|
||||||
|
|
||||||
if (player != null && player.isInFullscreen()) player.toggleFullscreen();
|
if (player != null && player.isFullscreen()) player.toggleFullscreen();
|
||||||
// This will show systemUI and pause the player.
|
// This will show systemUI and pause the player.
|
||||||
// User can tap on Play button and video will be in fullscreen mode again
|
// User can tap on Play button and video will be in fullscreen mode again
|
||||||
// Note for tablet: trying to avoid orientation changes since it's not easy to physically rotate the tablet every time
|
// Note for tablet: trying to avoid orientation changes since it's not easy to physically rotate the tablet every time
|
||||||
|
@ -1375,7 +1231,6 @@ public class VideoDetailFragment
|
||||||
contentRootLayoutHiding.setVisibility(View.INVISIBLE);
|
contentRootLayoutHiding.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//animateView(spinnerToolbar, false, 200);
|
|
||||||
animateView(thumbnailPlayButton, false, 50);
|
animateView(thumbnailPlayButton, false, 50);
|
||||||
animateView(detailDurationView, false, 100);
|
animateView(detailDurationView, false, 100);
|
||||||
animateView(detailPositionView, false, 100);
|
animateView(detailPositionView, false, 100);
|
||||||
|
@ -1392,7 +1247,7 @@ public class VideoDetailFragment
|
||||||
|
|
||||||
if(relatedStreamsLayout != null){
|
if(relatedStreamsLayout != null){
|
||||||
if(showRelatedStreams){
|
if(showRelatedStreams){
|
||||||
relatedStreamsLayout.setVisibility(player != null && player.isInFullscreen() ? View.GONE : View.INVISIBLE);
|
relatedStreamsLayout.setVisibility(player != null && player.isFullscreen() ? View.GONE : View.INVISIBLE);
|
||||||
}else{
|
}else{
|
||||||
relatedStreamsLayout.setVisibility(View.GONE);
|
relatedStreamsLayout.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
@ -1419,7 +1274,7 @@ public class VideoDetailFragment
|
||||||
getChildFragmentManager().beginTransaction()
|
getChildFragmentManager().beginTransaction()
|
||||||
.replace(R.id.relatedStreamsLayout, RelatedVideosFragment.getInstance(info))
|
.replace(R.id.relatedStreamsLayout, RelatedVideosFragment.getInstance(info))
|
||||||
.commitNow();
|
.commitNow();
|
||||||
relatedStreamsLayout.setVisibility(player != null && player.isInFullscreen() ? View.GONE : View.VISIBLE);
|
relatedStreamsLayout.setVisibility(player != null && player.isFullscreen() ? View.GONE : View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1506,9 +1361,6 @@ public class VideoDetailFragment
|
||||||
|
|
||||||
prepareDescription(info.getDescription());
|
prepareDescription(info.getDescription());
|
||||||
updateProgressInfo(info);
|
updateProgressInfo(info);
|
||||||
|
|
||||||
//animateView(spinnerToolbar, true, 500);
|
|
||||||
setupActionBar(info);
|
|
||||||
initThumbnailViews(info);
|
initThumbnailViews(info);
|
||||||
|
|
||||||
if (player == null || player.isPlayerStopped())
|
if (player == null || player.isPlayerStopped())
|
||||||
|
@ -1527,7 +1379,6 @@ public class VideoDetailFragment
|
||||||
case LIVE_STREAM:
|
case LIVE_STREAM:
|
||||||
case AUDIO_LIVE_STREAM:
|
case AUDIO_LIVE_STREAM:
|
||||||
detailControlsDownload.setVisibility(View.GONE);
|
detailControlsDownload.setVisibility(View.GONE);
|
||||||
spinnerToolbar.setVisibility(View.GONE);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if(info.getAudioStreams().isEmpty()) detailControlsBackground.setVisibility(View.GONE);
|
if(info.getAudioStreams().isEmpty()) detailControlsBackground.setVisibility(View.GONE);
|
||||||
|
@ -1535,7 +1386,6 @@ public class VideoDetailFragment
|
||||||
|| !info.getVideoOnlyStreams().isEmpty()) break;
|
|| !info.getVideoOnlyStreams().isEmpty()) break;
|
||||||
|
|
||||||
detailControlsPopup.setVisibility(View.GONE);
|
detailControlsPopup.setVisibility(View.GONE);
|
||||||
spinnerToolbar.setVisibility(View.GONE);
|
|
||||||
thumbnailPlayButton.setImageResource(R.drawable.ic_headset_white_24dp);
|
thumbnailPlayButton.setImageResource(R.drawable.ic_headset_white_24dp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1629,8 +1479,8 @@ public class VideoDetailFragment
|
||||||
}, e -> {
|
}, e -> {
|
||||||
if (DEBUG) e.printStackTrace();
|
if (DEBUG) e.printStackTrace();
|
||||||
}, () -> {
|
}, () -> {
|
||||||
animateView(positionView, false, 0);
|
positionView.setVisibility(View.GONE);
|
||||||
animateView(detailPositionView, false, 0);
|
detailPositionView.setVisibility(View.GONE);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1653,15 +1503,16 @@ public class VideoDetailFragment
|
||||||
@Override
|
@Override
|
||||||
public void onQueueUpdate(PlayQueue queue) {
|
public void onQueueUpdate(PlayQueue queue) {
|
||||||
playQueue = queue;
|
playQueue = queue;
|
||||||
|
StackItem stackWithQueue;
|
||||||
// This should be the only place where we push data to stack. It will allow to have live instance of PlayQueue with actual
|
// This should be the only place where we push data to stack. It will allow to have live instance of PlayQueue with actual
|
||||||
// information about deleted/added items inside Channel/Playlist queue and makes possible to have a history of played items
|
// information about deleted/added items inside Channel/Playlist queue and makes possible to have a history of played items
|
||||||
if (stack.isEmpty() || !stack.peek().getPlayQueue().equals(queue)) {
|
if (stack.isEmpty() || !stack.peek().getPlayQueue().equals(queue)) {
|
||||||
stack.push(new StackItem(serviceId, url, name, playQueue));
|
stack.push(new StackItem(serviceId, url, name, playQueue));
|
||||||
} else if (findQueueInStack(queue) != null) {
|
} else if ((stackWithQueue = findQueueInStack(queue)) != null) {
|
||||||
// On every MainPlayer service's destroy() playQueue gets disposed and no longer able to track progress.
|
// On every MainPlayer service's destroy() playQueue gets disposed and no longer able to track progress.
|
||||||
// That's why we update our cached disposed queue with the new one that is active and have the same history
|
// That's why we update our cached disposed queue with the new one that is active and have the same history
|
||||||
// Without that the cached playQueue will have an old recovery position
|
// Without that the cached playQueue will have an old recovery position
|
||||||
findQueueInStack(queue).setPlayQueue(queue);
|
stackWithQueue.setPlayQueue(queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
|
@ -1679,7 +1530,7 @@ public class VideoDetailFragment
|
||||||
restoreDefaultOrientation();
|
restoreDefaultOrientation();
|
||||||
break;
|
break;
|
||||||
case BasePlayer.STATE_PLAYING:
|
case BasePlayer.STATE_PLAYING:
|
||||||
if (positionView.getAlpha() != 1f
|
if (positionView.getAlpha() != 1.0f
|
||||||
&& player.getPlayQueue() != null
|
&& player.getPlayQueue() != null
|
||||||
&& player.getPlayQueue().getItem() != null
|
&& player.getPlayQueue().getItem() != null
|
||||||
&& player.getPlayQueue().getItem().getUrl().equals(url)) {
|
&& player.getPlayQueue().getItem().getUrl().equals(url)) {
|
||||||
|
@ -1725,7 +1576,7 @@ public class VideoDetailFragment
|
||||||
public void onPlayerError(ExoPlaybackException error) {
|
public void onPlayerError(ExoPlaybackException error) {
|
||||||
if (error.type == ExoPlaybackException.TYPE_SOURCE || error.type == ExoPlaybackException.TYPE_UNEXPECTED) {
|
if (error.type == ExoPlaybackException.TYPE_SOURCE || error.type == ExoPlaybackException.TYPE_UNEXPECTED) {
|
||||||
hideMainPlayer();
|
hideMainPlayer();
|
||||||
if (playerService != null && player.isInFullscreen())
|
if (playerService != null && player.isFullscreen())
|
||||||
player.toggleFullscreen();
|
player.toggleFullscreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1824,7 +1675,7 @@ public class VideoDetailFragment
|
||||||
|
|
||||||
// Listener implementation
|
// Listener implementation
|
||||||
public void hideSystemUiIfNeeded() {
|
public void hideSystemUiIfNeeded() {
|
||||||
if (player != null && player.isInFullscreen() && bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED)
|
if (player != null && player.isFullscreen() && bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED)
|
||||||
hideSystemUi();
|
hideSystemUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1897,11 +1748,19 @@ public class VideoDetailFragment
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldAskBeforeClearingQueue() {
|
private void replaceQueueIfUserConfirms(final Runnable onAllow) {
|
||||||
PlayQueue activeQueue = player != null ? player.getPlayQueue() : null;
|
@Nullable final PlayQueue activeQueue = player == null ? null : player.getPlayQueue();
|
||||||
|
|
||||||
// Player will have STATE_IDLE when a user pressed back button
|
// Player will have STATE_IDLE when a user pressed back button
|
||||||
return isClearingQueueConfirmationRequired(activity) && playerIsNotStopped()
|
if (isClearingQueueConfirmationRequired(activity)
|
||||||
&& activeQueue != null && !activeQueue.equals(playQueue) && activeQueue.getStreams().size() > 1;
|
&& playerIsNotStopped()
|
||||||
|
&& activeQueue != null
|
||||||
|
&& !activeQueue.equals(playQueue)
|
||||||
|
&& activeQueue.getStreams().size() > 1) {
|
||||||
|
showClearingQueueConfirmation(onAllow);
|
||||||
|
} else {
|
||||||
|
onAllow.run();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showClearingQueueConfirmation(Runnable onAllow) {
|
private void showClearingQueueConfirmation(Runnable onAllow) {
|
||||||
|
@ -1964,13 +1823,13 @@ public class VideoDetailFragment
|
||||||
// Disable click because overlay buttons located on top of buttons from the player
|
// Disable click because overlay buttons located on top of buttons from the player
|
||||||
setOverlayElementsClickable(false);
|
setOverlayElementsClickable(false);
|
||||||
hideSystemUiIfNeeded();
|
hideSystemUiIfNeeded();
|
||||||
boolean needToExpand = isLandscape()
|
// Conditions when the player should be expanded to fullscreen
|
||||||
|
if (isLandscape()
|
||||||
&& player != null
|
&& player != null
|
||||||
&& player.isPlaying()
|
&& player.isPlaying()
|
||||||
&& !player.isInFullscreen()
|
&& !player.isFullscreen()
|
||||||
&& !PlayerHelper.isTablet(activity)
|
&& !PlayerHelper.isTablet(activity)
|
||||||
&& player.videoPlayerSelected();
|
&& player.videoPlayerSelected()) player.toggleFullscreen();
|
||||||
if (needToExpand) player.toggleFullscreen();
|
|
||||||
break;
|
break;
|
||||||
case BottomSheetBehavior.STATE_COLLAPSED:
|
case BottomSheetBehavior.STATE_COLLAPSED:
|
||||||
// Re-enable clicks
|
// Re-enable clicks
|
||||||
|
@ -1979,7 +1838,7 @@ public class VideoDetailFragment
|
||||||
break;
|
break;
|
||||||
case BottomSheetBehavior.STATE_DRAGGING:
|
case BottomSheetBehavior.STATE_DRAGGING:
|
||||||
case BottomSheetBehavior.STATE_SETTLING:
|
case BottomSheetBehavior.STATE_SETTLING:
|
||||||
if (player != null && player.isInFullscreen()) showSystemUi();
|
if (player != null && player.isFullscreen()) showSystemUi();
|
||||||
if (player != null && player.isControlsVisible()) player.hideControls(0, 0);
|
if (player != null && player.isControlsVisible()) player.hideControls(0, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1997,8 +1856,8 @@ public class VideoDetailFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateOverlayData(@Nullable String title, @Nullable String uploader, @Nullable String thumbnailUrl) {
|
private void updateOverlayData(@Nullable String title, @Nullable String uploader, @Nullable String thumbnailUrl) {
|
||||||
overlayTitleTextView.setText(!TextUtils.isEmpty(title) ? title : "");
|
overlayTitleTextView.setText(TextUtils.isEmpty(title) ? "" : title);
|
||||||
overlayChannelTextView.setText(!TextUtils.isEmpty(uploader) ? uploader : "");
|
overlayChannelTextView.setText(TextUtils.isEmpty(uploader) ? "" : uploader);
|
||||||
overlayThumbnailImageView.setImageResource(R.drawable.dummy_thumbnail_dark);
|
overlayThumbnailImageView.setImageResource(R.drawable.dummy_thumbnail_dark);
|
||||||
if (!TextUtils.isEmpty(thumbnailUrl))
|
if (!TextUtils.isEmpty(thumbnailUrl))
|
||||||
imageLoader.displayImage(thumbnailUrl, overlayThumbnailImageView,
|
imageLoader.displayImage(thumbnailUrl, overlayThumbnailImageView,
|
||||||
|
@ -2006,8 +1865,7 @@ public class VideoDetailFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setOverlayPlayPauseImage() {
|
private void setOverlayPlayPauseImage() {
|
||||||
boolean playing = player != null && player.getPlayer().getPlayWhenReady();
|
int attr = player != null && player.getPlayer().getPlayWhenReady() ? R.attr.pause : R.attr.play;
|
||||||
int attr = playing ? R.attr.pause : R.attr.play;
|
|
||||||
overlayPlayPauseButton.setImageResource(ThemeHelper.resolveResourceIdFromAttr(activity, attr));
|
overlayPlayPauseButton.setImageResource(ThemeHelper.resolveResourceIdFromAttr(activity, attr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -436,16 +436,16 @@ public class SearchFragment
|
||||||
|
|
||||||
if (TextUtils.isEmpty(searchString) || TextUtils.isEmpty(searchEditText.getText())) {
|
if (TextUtils.isEmpty(searchString) || TextUtils.isEmpty(searchEditText.getText())) {
|
||||||
searchToolbarContainer.setTranslationX(100);
|
searchToolbarContainer.setTranslationX(100);
|
||||||
searchToolbarContainer.setAlpha(0f);
|
searchToolbarContainer.setAlpha(0.0f);
|
||||||
searchToolbarContainer.setVisibility(View.VISIBLE);
|
searchToolbarContainer.setVisibility(View.VISIBLE);
|
||||||
searchToolbarContainer.animate()
|
searchToolbarContainer.animate()
|
||||||
.translationX(0)
|
.translationX(0)
|
||||||
.alpha(1f)
|
.alpha(1.0f)
|
||||||
.setDuration(200)
|
.setDuration(200)
|
||||||
.setInterpolator(new DecelerateInterpolator()).start();
|
.setInterpolator(new DecelerateInterpolator()).start();
|
||||||
} else {
|
} else {
|
||||||
searchToolbarContainer.setTranslationX(0);
|
searchToolbarContainer.setTranslationX(0);
|
||||||
searchToolbarContainer.setAlpha(1f);
|
searchToolbarContainer.setAlpha(1.0f);
|
||||||
searchToolbarContainer.setVisibility(View.VISIBLE);
|
searchToolbarContainer.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -337,7 +337,7 @@ public final class BackgroundPlayer extends Service {
|
||||||
@Override
|
@Override
|
||||||
public void onPrepared(boolean playWhenReady) {
|
public void onPrepared(boolean playWhenReady) {
|
||||||
super.onPrepared(playWhenReady);
|
super.onPrepared(playWhenReady);
|
||||||
simpleExoPlayer.setVolume(1f);
|
simpleExoPlayer.setVolume(1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -158,7 +158,7 @@ public abstract class BasePlayer implements
|
||||||
// Playback
|
// Playback
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
protected static final float[] PLAYBACK_SPEEDS = {0.5f, 0.75f, 1f, 1.25f, 1.5f, 1.75f, 2f};
|
protected static final float[] PLAYBACK_SPEEDS = {0.5f, 0.75f, 1.0f, 1.25f, 1.5f, 1.75f, 2.0f};
|
||||||
|
|
||||||
protected PlayQueue playQueue;
|
protected PlayQueue playQueue;
|
||||||
protected PlayQueueAdapter playQueueAdapter;
|
protected PlayQueueAdapter playQueueAdapter;
|
||||||
|
@ -227,7 +227,7 @@ public abstract class BasePlayer implements
|
||||||
|
|
||||||
public void setup() {
|
public void setup() {
|
||||||
if (simpleExoPlayer == null) {
|
if (simpleExoPlayer == null) {
|
||||||
initPlayer(/*playOnInit=*/true);
|
initPlayer(true);
|
||||||
}
|
}
|
||||||
initListeners();
|
initListeners();
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ public abstract class BasePlayer implements
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean same = playQueue != null && playQueue.equals(queue);
|
boolean samePlayQueue = playQueue != null && playQueue.equals(queue);
|
||||||
|
|
||||||
final int repeatMode = intent.getIntExtra(REPEAT_MODE, getRepeatMode());
|
final int repeatMode = intent.getIntExtra(REPEAT_MODE, getRepeatMode());
|
||||||
final float playbackSpeed = intent.getFloatExtra(PLAYBACK_SPEED, getPlaybackSpeed());
|
final float playbackSpeed = intent.getFloatExtra(PLAYBACK_SPEED, getPlaybackSpeed());
|
||||||
|
@ -282,6 +282,14 @@ public abstract class BasePlayer implements
|
||||||
final boolean playbackSkipSilence = intent.getBooleanExtra(PLAYBACK_SKIP_SILENCE,
|
final boolean playbackSkipSilence = intent.getBooleanExtra(PLAYBACK_SKIP_SILENCE,
|
||||||
getPlaybackSkipSilence());
|
getPlaybackSkipSilence());
|
||||||
|
|
||||||
|
/*
|
||||||
|
* There are 3 situations when playback shouldn't be started from scratch (zero timestamp):
|
||||||
|
* 1. User pressed on a timestamp link and the same video should be rewound to that timestamp
|
||||||
|
* 2. User changed a player from, for example. main to popup, or from audio to main, etc
|
||||||
|
* 3. User chose to resume a video based on a saved timestamp from history of played videos
|
||||||
|
* In those cases time will be saved because re-init of the play queue is a not an instant task
|
||||||
|
* and requires network calls
|
||||||
|
* */
|
||||||
// seek to timestamp if stream is already playing
|
// seek to timestamp if stream is already playing
|
||||||
if (simpleExoPlayer != null
|
if (simpleExoPlayer != null
|
||||||
&& queue.size() == 1
|
&& queue.size() == 1
|
||||||
|
@ -289,21 +297,20 @@ public abstract class BasePlayer implements
|
||||||
&& playQueue.size() == 1
|
&& playQueue.size() == 1
|
||||||
&& playQueue.getItem() != null
|
&& playQueue.getItem() != null
|
||||||
&& queue.getItem().getUrl().equals(playQueue.getItem().getUrl())
|
&& queue.getItem().getUrl().equals(playQueue.getItem().getUrl())
|
||||||
&& queue.getItem().getRecoveryPosition() != PlayQueueItem.RECOVERY_UNSET
|
&& queue.getItem().getRecoveryPosition() != PlayQueueItem.RECOVERY_UNSET) {
|
||||||
&& simpleExoPlayer.getPlaybackState() != Player.STATE_IDLE) {
|
|
||||||
// Player can have state = IDLE when playback is stopped or failed and we should retry() in this case
|
// Player can have state = IDLE when playback is stopped or failed and we should retry() in this case
|
||||||
if (simpleExoPlayer.getPlaybackState() == Player.STATE_IDLE) simpleExoPlayer.retry();
|
if (simpleExoPlayer.getPlaybackState() == Player.STATE_IDLE) simpleExoPlayer.retry();
|
||||||
simpleExoPlayer.seekTo(playQueue.getIndex(), queue.getItem().getRecoveryPosition());
|
simpleExoPlayer.seekTo(playQueue.getIndex(), queue.getItem().getRecoveryPosition());
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else if (same && !playQueue.isDisposed() && simpleExoPlayer != null) {
|
} else if (samePlayQueue && !playQueue.isDisposed() && simpleExoPlayer != null) {
|
||||||
// Do not re-init the same PlayQueue. Save time
|
// Do not re-init the same PlayQueue. Save time
|
||||||
// Player can have state = IDLE when playback is stopped or failed and we should retry() in this case
|
// Player can have state = IDLE when playback is stopped or failed and we should retry() in this case
|
||||||
if (simpleExoPlayer.getPlaybackState() == Player.STATE_IDLE) simpleExoPlayer.retry();
|
if (simpleExoPlayer.getPlaybackState() == Player.STATE_IDLE) simpleExoPlayer.retry();
|
||||||
return;
|
return;
|
||||||
} else if (intent.getBooleanExtra(RESUME_PLAYBACK, false)
|
} else if (intent.getBooleanExtra(RESUME_PLAYBACK, false)
|
||||||
&& isPlaybackResumeEnabled()
|
&& isPlaybackResumeEnabled()
|
||||||
&& !same) {
|
&& !samePlayQueue) {
|
||||||
final PlayQueueItem item = queue.getItem();
|
final PlayQueueItem item = queue.getItem();
|
||||||
if (item != null && item.getRecoveryPosition() == PlayQueueItem.RECOVERY_UNSET) {
|
if (item != null && item.getRecoveryPosition() == PlayQueueItem.RECOVERY_UNSET) {
|
||||||
stateLoader = recordManager.loadStreamState(item)
|
stateLoader = recordManager.loadStreamState(item)
|
||||||
|
@ -313,19 +320,16 @@ public abstract class BasePlayer implements
|
||||||
.subscribe(
|
.subscribe(
|
||||||
state -> {
|
state -> {
|
||||||
queue.setRecovery(queue.getIndex(), state.getProgressTime());
|
queue.setRecovery(queue.getIndex(), state.getProgressTime());
|
||||||
initPlayback(queue, repeatMode, playbackSpeed, playbackPitch, playbackSkipSilence,
|
initPlayback(queue, repeatMode, playbackSpeed, playbackPitch, playbackSkipSilence, true);
|
||||||
/*playOnInit=*/true);
|
|
||||||
},
|
},
|
||||||
error -> {
|
error -> {
|
||||||
if (DEBUG) error.printStackTrace();
|
if (DEBUG) error.printStackTrace();
|
||||||
// In case any error we can start playback without history
|
// In case any error we can start playback without history
|
||||||
initPlayback(queue, repeatMode, playbackSpeed, playbackPitch, playbackSkipSilence,
|
initPlayback(queue, repeatMode, playbackSpeed, playbackPitch, playbackSkipSilence, true);
|
||||||
/*playOnInit=*/true);
|
|
||||||
},
|
},
|
||||||
() -> {
|
() -> {
|
||||||
// Completed but not found in history
|
// Completed but not found in history
|
||||||
initPlayback(queue, repeatMode, playbackSpeed, playbackPitch, playbackSkipSilence,
|
initPlayback(queue, repeatMode, playbackSpeed, playbackPitch, playbackSkipSilence, true);
|
||||||
/*playOnInit=*/true);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
databaseUpdateReactor.add(stateLoader);
|
databaseUpdateReactor.add(stateLoader);
|
||||||
|
@ -334,8 +338,7 @@ public abstract class BasePlayer implements
|
||||||
}
|
}
|
||||||
// Good to go...
|
// Good to go...
|
||||||
// In a case of equal PlayQueues we can re-init old one but only when it is disposed
|
// In a case of equal PlayQueues we can re-init old one but only when it is disposed
|
||||||
initPlayback(same ? playQueue : queue, repeatMode, playbackSpeed, playbackPitch, playbackSkipSilence,
|
initPlayback(samePlayQueue ? playQueue : queue, repeatMode, playbackSpeed, playbackPitch, playbackSkipSilence, true);
|
||||||
/*playOnInit=*/true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initPlayback(@NonNull final PlayQueue queue,
|
protected void initPlayback(@NonNull final PlayQueue queue,
|
||||||
|
|
|
@ -184,8 +184,6 @@ public final class MainPlayer extends Service {
|
||||||
playerImpl.destroy();
|
playerImpl.destroy();
|
||||||
}
|
}
|
||||||
if (notificationManager != null) notificationManager.cancel(NOTIFICATION_ID);
|
if (notificationManager != null) notificationManager.cancel(NOTIFICATION_ID);
|
||||||
playerImpl = null;
|
|
||||||
lockManager = null;
|
|
||||||
|
|
||||||
stopForeground(true);
|
stopForeground(true);
|
||||||
stopSelf();
|
stopSelf();
|
||||||
|
@ -197,7 +195,7 @@ public final class MainPlayer extends Service {
|
||||||
|
|
||||||
boolean isLandscape() {
|
boolean isLandscape() {
|
||||||
// DisplayMetrics from activity context knows about MultiWindow feature while DisplayMetrics from app context doesn't
|
// DisplayMetrics from activity context knows about MultiWindow feature while DisplayMetrics from app context doesn't
|
||||||
final DisplayMetrics metrics = playerImpl != null && playerImpl.getParentActivity() != null ?
|
final DisplayMetrics metrics = (playerImpl != null && playerImpl.getParentActivity() != null) ?
|
||||||
playerImpl.getParentActivity().getResources().getDisplayMetrics()
|
playerImpl.getParentActivity().getResources().getDisplayMetrics()
|
||||||
: getResources().getDisplayMetrics();
|
: getResources().getDisplayMetrics();
|
||||||
return metrics.heightPixels < metrics.widthPixels;
|
return metrics.heightPixels < metrics.widthPixels;
|
||||||
|
|
|
@ -797,9 +797,9 @@ public abstract class VideoPlayer extends BasePlayer
|
||||||
if (drawableId == -1) {
|
if (drawableId == -1) {
|
||||||
if (controlAnimationView.getVisibility() == View.VISIBLE) {
|
if (controlAnimationView.getVisibility() == View.VISIBLE) {
|
||||||
controlViewAnimator = ObjectAnimator.ofPropertyValuesHolder(controlAnimationView,
|
controlViewAnimator = ObjectAnimator.ofPropertyValuesHolder(controlAnimationView,
|
||||||
PropertyValuesHolder.ofFloat(View.ALPHA, 1f, 0f),
|
PropertyValuesHolder.ofFloat(View.ALPHA, 1.0f, 0.0f),
|
||||||
PropertyValuesHolder.ofFloat(View.SCALE_X, 1.4f, 1f),
|
PropertyValuesHolder.ofFloat(View.SCALE_X, 1.4f, 1.0f),
|
||||||
PropertyValuesHolder.ofFloat(View.SCALE_Y, 1.4f, 1f)
|
PropertyValuesHolder.ofFloat(View.SCALE_Y, 1.4f, 1.0f)
|
||||||
).setDuration(DEFAULT_CONTROLS_DURATION);
|
).setDuration(DEFAULT_CONTROLS_DURATION);
|
||||||
controlViewAnimator.addListener(new AnimatorListenerAdapter() {
|
controlViewAnimator.addListener(new AnimatorListenerAdapter() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -812,8 +812,8 @@ public abstract class VideoPlayer extends BasePlayer
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float scaleFrom = goneOnEnd ? 1f : 1f, scaleTo = goneOnEnd ? 1.8f : 1.4f;
|
float scaleFrom = goneOnEnd ? 1.0f : 1.0f, scaleTo = goneOnEnd ? 1.8f : 1.4f;
|
||||||
float alphaFrom = goneOnEnd ? 1f : 0f, alphaTo = goneOnEnd ? 0f : 1f;
|
float alphaFrom = goneOnEnd ? 1.0f : 0.0f, alphaTo = goneOnEnd ? 0.0f : 1.0f;
|
||||||
|
|
||||||
|
|
||||||
controlViewAnimator = ObjectAnimator.ofPropertyValuesHolder(controlAnimationView,
|
controlViewAnimator = ObjectAnimator.ofPropertyValuesHolder(controlAnimationView,
|
||||||
|
|
|
@ -270,14 +270,14 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
final float captionScale,
|
final float captionScale,
|
||||||
@NonNull final CaptionStyleCompat captionStyle) {
|
@NonNull final CaptionStyleCompat captionStyle) {
|
||||||
if (popupPlayerSelected()) {
|
if (popupPlayerSelected()) {
|
||||||
float captionRatio = (captionScale - 1f) / 5f + 1f;
|
float captionRatio = (captionScale - 1.0f) / 5.0f + 1.0f;
|
||||||
view.setFractionalTextSize(SubtitleView.DEFAULT_TEXT_SIZE_FRACTION * captionRatio);
|
view.setFractionalTextSize(SubtitleView.DEFAULT_TEXT_SIZE_FRACTION * captionRatio);
|
||||||
view.setApplyEmbeddedStyles(captionStyle.equals(CaptionStyleCompat.DEFAULT));
|
view.setApplyEmbeddedStyles(captionStyle.equals(CaptionStyleCompat.DEFAULT));
|
||||||
view.setStyle(captionStyle);
|
view.setStyle(captionStyle);
|
||||||
} else {
|
} else {
|
||||||
final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
|
final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
|
||||||
final int minimumLength = Math.min(metrics.heightPixels, metrics.widthPixels);
|
final int minimumLength = Math.min(metrics.heightPixels, metrics.widthPixels);
|
||||||
final float captionRatioInverse = 20f + 4f * (1f - captionScale);
|
final float captionRatioInverse = 20f + 4f * (1.0f - captionScale);
|
||||||
view.setFixedTextSize(TypedValue.COMPLEX_UNIT_PX,
|
view.setFixedTextSize(TypedValue.COMPLEX_UNIT_PX,
|
||||||
(float) minimumLength / captionRatioInverse);
|
(float) minimumLength / captionRatioInverse);
|
||||||
view.setApplyEmbeddedStyles(captionStyle.equals(CaptionStyleCompat.DEFAULT));
|
view.setApplyEmbeddedStyles(captionStyle.equals(CaptionStyleCompat.DEFAULT));
|
||||||
|
@ -300,7 +300,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
moreOptionsButton.setVisibility(View.GONE);
|
moreOptionsButton.setVisibility(View.GONE);
|
||||||
getTopControlsRoot().setOrientation(LinearLayout.HORIZONTAL);
|
getTopControlsRoot().setOrientation(LinearLayout.HORIZONTAL);
|
||||||
primaryControls.getLayoutParams().width = LinearLayout.LayoutParams.WRAP_CONTENT;
|
primaryControls.getLayoutParams().width = LinearLayout.LayoutParams.WRAP_CONTENT;
|
||||||
secondaryControls.setAlpha(1f);
|
secondaryControls.setAlpha(1.0f);
|
||||||
secondaryControls.setVisibility(View.VISIBLE);
|
secondaryControls.setVisibility(View.VISIBLE);
|
||||||
secondaryControls.setTranslationY(0);
|
secondaryControls.setTranslationY(0);
|
||||||
shareButton.setVisibility(View.GONE);
|
shareButton.setVisibility(View.GONE);
|
||||||
|
@ -333,7 +333,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
getTopControlsRoot().setClickable(true);
|
getTopControlsRoot().setClickable(true);
|
||||||
getTopControlsRoot().setFocusable(true);
|
getTopControlsRoot().setFocusable(true);
|
||||||
}
|
}
|
||||||
if (!isInFullscreen()) {
|
if (!isFullscreen()) {
|
||||||
titleTextView.setVisibility(View.GONE);
|
titleTextView.setVisibility(View.GONE);
|
||||||
channelTextView.setVisibility(View.GONE);
|
channelTextView.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
|
@ -602,10 +602,10 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
|
|
||||||
isFullscreen = !isFullscreen;
|
isFullscreen = !isFullscreen;
|
||||||
setControlsSize();
|
setControlsSize();
|
||||||
fragmentListener.onFullscreenStateChanged(isInFullscreen());
|
fragmentListener.onFullscreenStateChanged(isFullscreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isInFullscreen()) {
|
if (!isFullscreen()) {
|
||||||
titleTextView.setVisibility(View.GONE);
|
titleTextView.setVisibility(View.GONE);
|
||||||
channelTextView.setVisibility(View.GONE);
|
channelTextView.setVisibility(View.GONE);
|
||||||
playerCloseButton.setVisibility(videoPlayerSelected() ? View.VISIBLE : View.GONE);
|
playerCloseButton.setVisibility(videoPlayerSelected() ? View.VISIBLE : View.GONE);
|
||||||
|
@ -674,7 +674,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View v) {
|
public boolean onLongClick(View v) {
|
||||||
if (v.getId() == moreOptionsButton.getId() && isInFullscreen()) {
|
if (v.getId() == moreOptionsButton.getId() && isFullscreen()) {
|
||||||
fragmentListener.onMoreOptionsLongClicked();
|
fragmentListener.onMoreOptionsLongClicked();
|
||||||
hideControls(0, 0);
|
hideControls(0, 0);
|
||||||
hideSystemUIIfNeeded();
|
hideSystemUIIfNeeded();
|
||||||
|
@ -690,7 +690,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
updatePlaybackButtons();
|
updatePlaybackButtons();
|
||||||
|
|
||||||
getControlsRoot().setVisibility(View.INVISIBLE);
|
getControlsRoot().setVisibility(View.INVISIBLE);
|
||||||
animateView(queueLayout, SLIDE_AND_ALPHA, /*visible=*/true,
|
animateView(queueLayout, SLIDE_AND_ALPHA,true,
|
||||||
DEFAULT_CONTROLS_DURATION);
|
DEFAULT_CONTROLS_DURATION);
|
||||||
|
|
||||||
itemsList.scrollToPosition(playQueue.getIndex());
|
itemsList.scrollToPosition(playQueue.getIndex());
|
||||||
|
@ -699,7 +699,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
public void onQueueClosed() {
|
public void onQueueClosed() {
|
||||||
if (!queueVisible) return;
|
if (!queueVisible) return;
|
||||||
|
|
||||||
animateView(queueLayout, SLIDE_AND_ALPHA, /*visible=*/false,
|
animateView(queueLayout, SLIDE_AND_ALPHA,false,
|
||||||
DEFAULT_CONTROLS_DURATION, 0, () -> {
|
DEFAULT_CONTROLS_DURATION, 0, () -> {
|
||||||
// Even when queueLayout is GONE it receives touch events and ruins normal behavior of the app. This line fixes it
|
// Even when queueLayout is GONE it receives touch events and ruins normal behavior of the app. This line fixes it
|
||||||
queueLayout.setTranslationY(-queueLayout.getHeight() * 5);
|
queueLayout.setTranslationY(-queueLayout.getHeight() * 5);
|
||||||
|
@ -765,12 +765,12 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
boolean showButton = videoPlayerSelected() && (orientationLocked || isVerticalVideo || tabletInLandscape);
|
boolean showButton = videoPlayerSelected() && (orientationLocked || isVerticalVideo || tabletInLandscape);
|
||||||
screenRotationButton.setVisibility(showButton ? View.VISIBLE : View.GONE);
|
screenRotationButton.setVisibility(showButton ? View.VISIBLE : View.GONE);
|
||||||
screenRotationButton.setImageDrawable(service.getResources().getDrawable(
|
screenRotationButton.setImageDrawable(service.getResources().getDrawable(
|
||||||
isInFullscreen() ? R.drawable.ic_fullscreen_exit_white : R.drawable.ic_fullscreen_white));
|
isFullscreen() ? R.drawable.ic_fullscreen_exit_white : R.drawable.ic_fullscreen_white));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareOrientation() {
|
private void prepareOrientation() {
|
||||||
boolean orientationLocked = PlayerHelper.globalScreenOrientationLocked(service);
|
boolean orientationLocked = PlayerHelper.globalScreenOrientationLocked(service);
|
||||||
if (orientationLocked && isInFullscreen() && service.isLandscape() == isVerticalVideo && fragmentListener != null)
|
if (orientationLocked && isFullscreen() && service.isLandscape() == isVerticalVideo && fragmentListener != null)
|
||||||
fragmentListener.onScreenRotationButtonClicked();
|
fragmentListener.onScreenRotationButtonClicked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -893,7 +893,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
@Override
|
@Override
|
||||||
public void onBlocked() {
|
public void onBlocked() {
|
||||||
super.onBlocked();
|
super.onBlocked();
|
||||||
playPauseButton.setImageResource(R.drawable.ic_pause_white);
|
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white);
|
||||||
animatePlayButtons(false, 100);
|
animatePlayButtons(false, 100);
|
||||||
getRootView().setKeepScreenOn(false);
|
getRootView().setKeepScreenOn(false);
|
||||||
|
|
||||||
|
@ -1185,7 +1185,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
return distanceFromCloseButton(popupMotionEvent) <= getClosingRadius();
|
return distanceFromCloseButton(popupMotionEvent) <= getClosingRadius();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInFullscreen() {
|
public boolean isFullscreen() {
|
||||||
return isFullscreen;
|
return isFullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1216,8 +1216,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
getControlsVisibilityHandler().removeCallbacksAndMessages(null);
|
getControlsVisibilityHandler().removeCallbacksAndMessages(null);
|
||||||
getControlsVisibilityHandler().postDelayed(() ->
|
getControlsVisibilityHandler().postDelayed(() ->
|
||||||
animateView(getControlsRoot(), false, duration, 0,
|
animateView(getControlsRoot(), false, duration, 0,
|
||||||
this::hideSystemUIIfNeeded),
|
this::hideSystemUIIfNeeded), delay
|
||||||
/*delayMillis=*/delay
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1225,24 +1224,13 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
if (playQueue == null)
|
if (playQueue == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (playQueue.getIndex() == 0)
|
playPreviousButton.setVisibility(playQueue.getIndex() == 0 ? View.INVISIBLE : View.VISIBLE);
|
||||||
playPreviousButton.setVisibility(View.INVISIBLE);
|
playNextButton.setVisibility(playQueue.getIndex() + 1 == playQueue.getStreams().size() ? View.INVISIBLE : View.VISIBLE);
|
||||||
else
|
queueButton.setVisibility(playQueue.getStreams().size() <= 1 || popupPlayerSelected() ? View.GONE : View.VISIBLE);
|
||||||
playPreviousButton.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
if (playQueue.getIndex() + 1 == playQueue.getStreams().size())
|
|
||||||
playNextButton.setVisibility(View.INVISIBLE);
|
|
||||||
else
|
|
||||||
playNextButton.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
if (playQueue.getStreams().size() <= 1 || popupPlayerSelected())
|
|
||||||
queueButton.setVisibility(View.GONE);
|
|
||||||
else
|
|
||||||
queueButton.setVisibility(View.VISIBLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showSystemUIPartially() {
|
private void showSystemUIPartially() {
|
||||||
if (isInFullscreen() && getParentActivity() != null) {
|
if (isFullscreen() && getParentActivity() != null) {
|
||||||
int visibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
|
int visibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
|
||||||
getParentActivity().getWindow().getDecorView().setSystemUiVisibility(visibility);
|
getParentActivity().getWindow().getDecorView().setSystemUiVisibility(visibility);
|
||||||
}
|
}
|
||||||
|
@ -1330,7 +1318,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
|
|
||||||
public void checkLandscape() {
|
public void checkLandscape() {
|
||||||
AppCompatActivity parent = getParentActivity();
|
AppCompatActivity parent = getParentActivity();
|
||||||
boolean videoInLandscapeButNotInFullscreen = service.isLandscape() && !isInFullscreen() && videoPlayerSelected() && !audioOnly;
|
boolean videoInLandscapeButNotInFullscreen = service.isLandscape() && !isFullscreen() && videoPlayerSelected() && !audioOnly;
|
||||||
boolean playingState = getCurrentState() != STATE_COMPLETED && getCurrentState() != STATE_PAUSED;
|
boolean playingState = getCurrentState() != STATE_COMPLETED && getCurrentState() != STATE_PAUSED;
|
||||||
if (parent != null && videoInLandscapeButNotInFullscreen && playingState && !PlayerHelper.isTablet(service))
|
if (parent != null && videoInLandscapeButNotInFullscreen && playingState && !PlayerHelper.isTablet(service))
|
||||||
toggleFullscreen();
|
toggleFullscreen();
|
||||||
|
@ -1421,7 +1409,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
if (DEBUG) Log.d(TAG, "initPopup() called");
|
if (DEBUG) Log.d(TAG, "initPopup() called");
|
||||||
|
|
||||||
// Popup is already added to windowManager
|
// Popup is already added to windowManager
|
||||||
if (isPopupHasParent()) return;
|
if (popupHasParent()) return;
|
||||||
|
|
||||||
updateScreenSize();
|
updateScreenSize();
|
||||||
|
|
||||||
|
@ -1430,13 +1418,10 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(service);
|
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(service);
|
||||||
popupWidth = popupRememberSizeAndPos ? sharedPreferences.getFloat(POPUP_SAVED_WIDTH, defaultSize) : defaultSize;
|
popupWidth = popupRememberSizeAndPos ? sharedPreferences.getFloat(POPUP_SAVED_WIDTH, defaultSize) : defaultSize;
|
||||||
popupHeight = getMinimumVideoHeight(popupWidth);
|
popupHeight = getMinimumVideoHeight(popupWidth);
|
||||||
final int layoutParamType = Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O ?
|
|
||||||
WindowManager.LayoutParams.TYPE_PHONE :
|
|
||||||
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
|
||||||
|
|
||||||
popupLayoutParams = new WindowManager.LayoutParams(
|
popupLayoutParams = new WindowManager.LayoutParams(
|
||||||
(int) popupWidth, (int) popupHeight,
|
(int) popupWidth, (int) popupHeight,
|
||||||
layoutParamType,
|
popupLayoutParamType(),
|
||||||
IDLE_WINDOW_FLAGS,
|
IDLE_WINDOW_FLAGS,
|
||||||
PixelFormat.TRANSLUCENT);
|
PixelFormat.TRANSLUCENT);
|
||||||
popupLayoutParams.gravity = Gravity.LEFT | Gravity.TOP;
|
popupLayoutParams.gravity = Gravity.LEFT | Gravity.TOP;
|
||||||
|
@ -1470,15 +1455,12 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
closeOverlayView = View.inflate(service, R.layout.player_popup_close_overlay, null);
|
closeOverlayView = View.inflate(service, R.layout.player_popup_close_overlay, null);
|
||||||
closeOverlayButton = closeOverlayView.findViewById(R.id.closeButton);
|
closeOverlayButton = closeOverlayView.findViewById(R.id.closeButton);
|
||||||
|
|
||||||
final int layoutParamType = Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O ?
|
|
||||||
WindowManager.LayoutParams.TYPE_PHONE :
|
|
||||||
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
|
||||||
final int flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
|
final int flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
|
||||||
| WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
|
| WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
|
||||||
|
|
||||||
WindowManager.LayoutParams closeOverlayLayoutParams = new WindowManager.LayoutParams(
|
WindowManager.LayoutParams closeOverlayLayoutParams = new WindowManager.LayoutParams(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT,
|
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
layoutParamType,
|
popupLayoutParamType(),
|
||||||
flags,
|
flags,
|
||||||
PixelFormat.TRANSLUCENT);
|
PixelFormat.TRANSLUCENT);
|
||||||
closeOverlayLayoutParams.gravity = Gravity.LEFT | Gravity.TOP;
|
closeOverlayLayoutParams.gravity = Gravity.LEFT | Gravity.TOP;
|
||||||
|
@ -1600,6 +1582,12 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
windowManager.updateViewLayout(getRootView(), popupLayoutParams);
|
windowManager.updateViewLayout(getRootView(), popupLayoutParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int popupLayoutParamType() {
|
||||||
|
return Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O ?
|
||||||
|
WindowManager.LayoutParams.TYPE_PHONE :
|
||||||
|
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
||||||
|
}
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// Misc
|
// Misc
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
@ -1617,7 +1605,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
|
|
||||||
public void removePopupFromView() {
|
public void removePopupFromView() {
|
||||||
boolean isCloseOverlayHasParent = closeOverlayView != null && closeOverlayView.getParent() != null;
|
boolean isCloseOverlayHasParent = closeOverlayView != null && closeOverlayView.getParent() != null;
|
||||||
if (isPopupHasParent())
|
if (popupHasParent())
|
||||||
windowManager.removeView(getRootView());
|
windowManager.removeView(getRootView());
|
||||||
if (isCloseOverlayHasParent)
|
if (isCloseOverlayHasParent)
|
||||||
windowManager.removeView(closeOverlayView);
|
windowManager.removeView(closeOverlayView);
|
||||||
|
@ -1651,7 +1639,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPopupHasParent() {
|
private boolean popupHasParent() {
|
||||||
View root = getRootView();
|
View root = getRootView();
|
||||||
return root != null && root.getLayoutParams() instanceof WindowManager.LayoutParams && root.getParent() != null;
|
return root != null && root.getLayoutParams() instanceof WindowManager.LayoutParams && root.getParent() != null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,10 +160,7 @@ public class PlayerGestureListener extends GestureDetector.SimpleOnGestureListen
|
||||||
|
|
||||||
isMovingInMain = true;
|
isMovingInMain = true;
|
||||||
|
|
||||||
boolean acceptVolumeArea = initialEvent.getX() > playerImpl.getRootView().getWidth() / 2.0;
|
if (isVolumeGestureEnabled && initialEvent.getX() > playerImpl.getRootView().getWidth() / 2.0) {
|
||||||
boolean acceptBrightnessArea = initialEvent.getX() <= playerImpl.getRootView().getWidth() / 2.0;
|
|
||||||
|
|
||||||
if (isVolumeGestureEnabled && acceptVolumeArea) {
|
|
||||||
playerImpl.getVolumeProgressBar().incrementProgressBy((int) distanceY);
|
playerImpl.getVolumeProgressBar().incrementProgressBy((int) distanceY);
|
||||||
float currentProgressPercent =
|
float currentProgressPercent =
|
||||||
(float) playerImpl.getVolumeProgressBar().getProgress() / playerImpl.getMaxGestureLength();
|
(float) playerImpl.getVolumeProgressBar().getProgress() / playerImpl.getMaxGestureLength();
|
||||||
|
@ -172,14 +169,11 @@ public class PlayerGestureListener extends GestureDetector.SimpleOnGestureListen
|
||||||
|
|
||||||
if (DEBUG) Log.d(TAG, "onScroll().volumeControl, currentVolume = " + currentVolume);
|
if (DEBUG) Log.d(TAG, "onScroll().volumeControl, currentVolume = " + currentVolume);
|
||||||
|
|
||||||
final int resId =
|
playerImpl.getVolumeImageView().setImageDrawable(
|
||||||
currentProgressPercent <= 0 ? R.drawable.ic_volume_off_white_72dp
|
AppCompatResources.getDrawable(service, currentProgressPercent <= 0 ? R.drawable.ic_volume_off_white_72dp
|
||||||
: currentProgressPercent < 0.25 ? R.drawable.ic_volume_mute_white_72dp
|
: currentProgressPercent < 0.25 ? R.drawable.ic_volume_mute_white_72dp
|
||||||
: currentProgressPercent < 0.75 ? R.drawable.ic_volume_down_white_72dp
|
: currentProgressPercent < 0.75 ? R.drawable.ic_volume_down_white_72dp
|
||||||
: R.drawable.ic_volume_up_white_72dp;
|
: R.drawable.ic_volume_up_white_72dp)
|
||||||
|
|
||||||
playerImpl.getVolumeImageView().setImageDrawable(
|
|
||||||
AppCompatResources.getDrawable(service, resId)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (playerImpl.getVolumeRelativeLayout().getVisibility() != View.VISIBLE) {
|
if (playerImpl.getVolumeRelativeLayout().getVisibility() != View.VISIBLE) {
|
||||||
|
@ -188,7 +182,7 @@ public class PlayerGestureListener extends GestureDetector.SimpleOnGestureListen
|
||||||
if (playerImpl.getBrightnessRelativeLayout().getVisibility() == View.VISIBLE) {
|
if (playerImpl.getBrightnessRelativeLayout().getVisibility() == View.VISIBLE) {
|
||||||
playerImpl.getBrightnessRelativeLayout().setVisibility(View.GONE);
|
playerImpl.getBrightnessRelativeLayout().setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
} else if (isBrightnessGestureEnabled && acceptBrightnessArea) {
|
} else if (isBrightnessGestureEnabled && initialEvent.getX() <= playerImpl.getRootView().getWidth() / 2.0) {
|
||||||
Activity parent = playerImpl.getParentActivity();
|
Activity parent = playerImpl.getParentActivity();
|
||||||
if (parent == null) return true;
|
if (parent == null) return true;
|
||||||
|
|
||||||
|
@ -203,13 +197,11 @@ public class PlayerGestureListener extends GestureDetector.SimpleOnGestureListen
|
||||||
|
|
||||||
if (DEBUG) Log.d(TAG, "onScroll().brightnessControl, currentBrightness = " + currentProgressPercent);
|
if (DEBUG) Log.d(TAG, "onScroll().brightnessControl, currentBrightness = " + currentProgressPercent);
|
||||||
|
|
||||||
final int resId =
|
|
||||||
currentProgressPercent < 0.25 ? R.drawable.ic_brightness_low_white_72dp
|
|
||||||
: currentProgressPercent < 0.75 ? R.drawable.ic_brightness_medium_white_72dp
|
|
||||||
: R.drawable.ic_brightness_high_white_72dp;
|
|
||||||
|
|
||||||
playerImpl.getBrightnessImageView().setImageDrawable(
|
playerImpl.getBrightnessImageView().setImageDrawable(
|
||||||
AppCompatResources.getDrawable(service, resId)
|
AppCompatResources.getDrawable(service,
|
||||||
|
currentProgressPercent < 0.25 ? R.drawable.ic_brightness_low_white_72dp
|
||||||
|
: currentProgressPercent < 0.75 ? R.drawable.ic_brightness_medium_white_72dp
|
||||||
|
: R.drawable.ic_brightness_high_white_72dp)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (playerImpl.getBrightnessRelativeLayout().getVisibility() != View.VISIBLE) {
|
if (playerImpl.getBrightnessRelativeLayout().getVisibility() != View.VISIBLE) {
|
||||||
|
@ -247,7 +239,7 @@ public class PlayerGestureListener extends GestureDetector.SimpleOnGestureListen
|
||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
case MotionEvent.ACTION_DOWN:
|
case MotionEvent.ACTION_DOWN:
|
||||||
case MotionEvent.ACTION_MOVE:
|
case MotionEvent.ACTION_MOVE:
|
||||||
v.getParent().requestDisallowInterceptTouchEvent(playerImpl.isInFullscreen());
|
v.getParent().requestDisallowInterceptTouchEvent(playerImpl.isFullscreen());
|
||||||
return true;
|
return true;
|
||||||
case MotionEvent.ACTION_UP:
|
case MotionEvent.ACTION_UP:
|
||||||
v.getParent().requestDisallowInterceptTouchEvent(false);
|
v.getParent().requestDisallowInterceptTouchEvent(false);
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class AudioReactor implements AudioManager.OnAudioFocusChangeListener,
|
||||||
private void onAudioFocusGain() {
|
private void onAudioFocusGain() {
|
||||||
Log.d(TAG, "onAudioFocusGain() called");
|
Log.d(TAG, "onAudioFocusGain() called");
|
||||||
player.setVolume(DUCK_AUDIO_TO);
|
player.setVolume(DUCK_AUDIO_TO);
|
||||||
animateAudio(DUCK_AUDIO_TO, 1f);
|
animateAudio(DUCK_AUDIO_TO, 1.0f);
|
||||||
|
|
||||||
if (PlayerHelper.isResumeAfterAudioFocusGain(context)) {
|
if (PlayerHelper.isResumeAfterAudioFocusGain(context)) {
|
||||||
player.setPlayWhenReady(true);
|
player.setPlayWhenReady(true);
|
||||||
|
|
|
@ -222,14 +222,10 @@ public class PlayerHelper {
|
||||||
|
|
||||||
@AutoplayType
|
@AutoplayType
|
||||||
public static int getAutoplayType(@NonNull final Context context) {
|
public static int getAutoplayType(@NonNull final Context context) {
|
||||||
final String defaultType = context.getString(R.string.autoplay_wifi_key);
|
final String type = getAutoplayType(context, context.getString(R.string.autoplay_wifi_key));
|
||||||
final String always = context.getString(R.string.autoplay_always_key);
|
if (type.equals(context.getString(R.string.autoplay_always_key))) {
|
||||||
final String never = context.getString(R.string.autoplay_never_key);
|
|
||||||
|
|
||||||
final String type = getAutoplayType(context, defaultType);
|
|
||||||
if (type.equals(always)) {
|
|
||||||
return AUTOPLAY_TYPE_ALWAYS;
|
return AUTOPLAY_TYPE_ALWAYS;
|
||||||
} else if (type.equals(never)) {
|
} else if (type.equals(context.getString(R.string.autoplay_never_key))) {
|
||||||
return AUTOPLAY_TYPE_NEVER;
|
return AUTOPLAY_TYPE_NEVER;
|
||||||
} else {
|
} else {
|
||||||
return AUTOPLAY_TYPE_WIFI;
|
return AUTOPLAY_TYPE_WIFI;
|
||||||
|
@ -307,12 +303,12 @@ public class PlayerHelper {
|
||||||
* Very small - 0.25f, Small - 0.5f, Normal - 1.0f, Large - 1.5f, Very Large - 2.0f
|
* Very small - 0.25f, Small - 0.5f, Normal - 1.0f, Large - 1.5f, Very Large - 2.0f
|
||||||
* */
|
* */
|
||||||
public static float getCaptionScale(@NonNull final Context context) {
|
public static float getCaptionScale(@NonNull final Context context) {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return 1f;
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return 1.0f;
|
||||||
|
|
||||||
final CaptioningManager captioningManager = (CaptioningManager)
|
final CaptioningManager captioningManager = (CaptioningManager)
|
||||||
context.getSystemService(Context.CAPTIONING_SERVICE);
|
context.getSystemService(Context.CAPTIONING_SERVICE);
|
||||||
if (captioningManager == null || !captioningManager.isEnabled()) {
|
if (captioningManager == null || !captioningManager.isEnabled()) {
|
||||||
return 1f;
|
return 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return captioningManager.getFontScale();
|
return captioningManager.getFontScale();
|
||||||
|
@ -330,8 +326,8 @@ public class PlayerHelper {
|
||||||
public static boolean globalScreenOrientationLocked(Context context) {
|
public static boolean globalScreenOrientationLocked(Context context) {
|
||||||
// 1: Screen orientation changes using accelerometer
|
// 1: Screen orientation changes using accelerometer
|
||||||
// 0: Screen orientation is locked
|
// 0: Screen orientation is locked
|
||||||
return !(android.provider.Settings.System.getInt(
|
return android.provider.Settings.System.getInt(
|
||||||
context.getContentResolver(), Settings.System.ACCELEROMETER_ROTATION, 0) == 1);
|
context.getContentResolver(), Settings.System.ACCELEROMETER_ROTATION, 0) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isTablet(@NonNull final Context context) {
|
public static boolean isTablet(@NonNull final Context context) {
|
||||||
|
|
|
@ -158,7 +158,7 @@ public class OggFromWebMWriter implements Closeable {
|
||||||
switch (webm_track.kind) {
|
switch (webm_track.kind) {
|
||||||
case Audio:
|
case Audio:
|
||||||
resolution = getSampleFrequencyFromTrack(webm_track.bMetadata);
|
resolution = getSampleFrequencyFromTrack(webm_track.bMetadata);
|
||||||
if (resolution == 0f) {
|
if (resolution == 0.0f) {
|
||||||
throw new RuntimeException("cannot get the audio sample rate");
|
throw new RuntimeException("cannot get the audio sample rate");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -167,7 +167,7 @@ public class OggFromWebMWriter implements Closeable {
|
||||||
if (webm_track.defaultDuration == 0) {
|
if (webm_track.defaultDuration == 0) {
|
||||||
throw new RuntimeException("missing default frame time");
|
throw new RuntimeException("missing default frame time");
|
||||||
}
|
}
|
||||||
resolution = 1000f / ((float) webm_track.defaultDuration / webm_segment.info.timecodeScale);
|
resolution = 1000.0f / ((float) webm_track.defaultDuration / webm_segment.info.timecodeScale);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("not implemented");
|
throw new RuntimeException("not implemented");
|
||||||
|
@ -358,7 +358,7 @@ public class OggFromWebMWriter implements Closeable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearSegmentTable() {
|
private void clearSegmentTable() {
|
||||||
|
|
|
@ -292,7 +292,7 @@ public class SubtitleConverter {
|
||||||
|
|
||||||
time += Integer.parseInt(units[0]) * 3600000;// hours
|
time += Integer.parseInt(units[0]) * 3600000;// hours
|
||||||
time += Integer.parseInt(units[1]) * 60000;//minutes
|
time += Integer.parseInt(units[1]) * 60000;//minutes
|
||||||
time += Float.parseFloat(units[2]) * 1000f;// seconds and milliseconds (if present)
|
time += Float.parseFloat(units[2]) * 1000.0f;// seconds and milliseconds (if present)
|
||||||
|
|
||||||
// frames and sub-frames are ignored (not implemented)
|
// frames and sub-frames are ignored (not implemented)
|
||||||
// time += units[3] * fps;
|
// time += units[3] * fps;
|
||||||
|
|
|
@ -612,7 +612,7 @@ public class WebMWriter implements Closeable {
|
||||||
|
|
||||||
int offset = withLength ? 1 : 0;
|
int offset = withLength ? 1 : 0;
|
||||||
byte[] buffer = new byte[offset + length];
|
byte[] buffer = new byte[offset + length];
|
||||||
long marker = (long) Math.floor((length - 1f) / 8f);
|
long marker = (long) Math.floor((length - 1.0f) / 8.0f);
|
||||||
|
|
||||||
float mul = 1;
|
float mul = 1;
|
||||||
for (int i = length - 1; i >= 0; i--, mul *= 0x100) {
|
for (int i = length - 1; i >= 0; i--, mul *= 0x100) {
|
||||||
|
|
|
@ -73,9 +73,7 @@ public class NavigationHelper {
|
||||||
if (cacheKey != null) intent.putExtra(VideoPlayer.PLAY_QUEUE_KEY, cacheKey);
|
if (cacheKey != null) intent.putExtra(VideoPlayer.PLAY_QUEUE_KEY, cacheKey);
|
||||||
if (quality != null) intent.putExtra(VideoPlayer.PLAYBACK_QUALITY, quality);
|
if (quality != null) intent.putExtra(VideoPlayer.PLAYBACK_QUALITY, quality);
|
||||||
intent.putExtra(VideoPlayer.RESUME_PLAYBACK, resumePlayback);
|
intent.putExtra(VideoPlayer.RESUME_PLAYBACK, resumePlayback);
|
||||||
|
intent.putExtra(VideoPlayer.PLAYER_TYPE, VideoPlayer.PLAYER_TYPE_VIDEO);
|
||||||
int playerType = intent.getIntExtra(VideoPlayer.PLAYER_TYPE, VideoPlayer.PLAYER_TYPE_VIDEO);
|
|
||||||
intent.putExtra(VideoPlayer.PLAYER_TYPE, playerType);
|
|
||||||
|
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +120,24 @@ public class NavigationHelper {
|
||||||
|
|
||||||
public static void playOnMainPlayer(final FragmentManager fragmentManager, final PlayQueue queue, boolean autoPlay) {
|
public static void playOnMainPlayer(final FragmentManager fragmentManager, final PlayQueue queue, boolean autoPlay) {
|
||||||
PlayQueueItem currentStream = queue.getItem();
|
PlayQueueItem currentStream = queue.getItem();
|
||||||
NavigationHelper.openVideoDetailFragment(fragmentManager, currentStream.getServiceId(), currentStream.getUrl(), currentStream.getTitle(), autoPlay, queue);
|
openVideoDetailFragment(fragmentManager, currentStream.getServiceId(), currentStream.getUrl(), currentStream.getTitle(), autoPlay, queue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void playOnMainPlayer(@NonNull final Context context,
|
||||||
|
@NonNull final PlayQueue queue,
|
||||||
|
@NonNull final StreamingService.LinkType linkType,
|
||||||
|
@NonNull final String url,
|
||||||
|
@NonNull final String title,
|
||||||
|
final boolean autoPlay,
|
||||||
|
final boolean resumePlayback) {
|
||||||
|
|
||||||
|
Intent intent = getPlayerIntent(context, MainActivity.class, queue, resumePlayback);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
intent.putExtra(Constants.KEY_LINK_TYPE, linkType);
|
||||||
|
intent.putExtra(Constants.KEY_URL, url);
|
||||||
|
intent.putExtra(Constants.KEY_TITLE, title);
|
||||||
|
intent.putExtra(VideoDetailFragment.AUTO_PLAY, autoPlay);
|
||||||
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void playOnPopupPlayer(final Context context, final PlayQueue queue, final boolean resumePlayback) {
|
public static void playOnPopupPlayer(final Context context, final PlayQueue queue, final boolean resumePlayback) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class ExpandableSurfaceView extends SurfaceView {
|
||||||
private int resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIT;
|
private int resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIT;
|
||||||
private int baseHeight = 0;
|
private int baseHeight = 0;
|
||||||
private int maxHeight = 0;
|
private int maxHeight = 0;
|
||||||
private float videoAspectRatio = 0f;
|
private float videoAspectRatio = 0.0f;
|
||||||
private float scaleX = 1.0f;
|
private float scaleX = 1.0f;
|
||||||
private float scaleY = 1.0f;
|
private float scaleY = 1.0f;
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ public class ExpandableSurfaceView extends SurfaceView {
|
||||||
@Override
|
@Override
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
if (videoAspectRatio == 0f) return;
|
if (videoAspectRatio == 0.0f) return;
|
||||||
|
|
||||||
int width = MeasureSpec.getSize(widthMeasureSpec);
|
int width = MeasureSpec.getSize(widthMeasureSpec);
|
||||||
boolean verticalVideo = videoAspectRatio < 1;
|
boolean verticalVideo = videoAspectRatio < 1;
|
||||||
|
|
|
@ -89,7 +89,7 @@ public abstract class Postprocessing implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTemporalDir(@NonNull File directory) {
|
public void setTemporalDir(@NonNull File directory) {
|
||||||
long rnd = (int) (Math.random() * 100000f);
|
long rnd = (int) (Math.random() * 100000.0f);
|
||||||
tempFile = new File(directory, rnd + "_" + System.nanoTime() + ".tmp");
|
tempFile = new File(directory, rnd + "_" + System.nanoTime() + ".tmp");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -198,7 +198,7 @@ public class MissionAdapter extends Adapter<ViewHolder> implements Handler.Callb
|
||||||
} else {
|
} else {
|
||||||
h.progress.setMarquee(false);
|
h.progress.setMarquee(false);
|
||||||
h.status.setText("100%");
|
h.status.setText("100%");
|
||||||
h.progress.setProgress(1f);
|
h.progress.setProgress(1.0f);
|
||||||
h.size.setText(Utility.formatBytes(item.mission.length));
|
h.size.setText(Utility.formatBytes(item.mission.length));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,7 @@ public class MissionAdapter extends Adapter<ViewHolder> implements Handler.Callb
|
||||||
double progress;
|
double progress;
|
||||||
if (mission.unknownLength) {
|
if (mission.unknownLength) {
|
||||||
progress = Double.NaN;
|
progress = Double.NaN;
|
||||||
h.progress.setProgress(0f);
|
h.progress.setProgress(0.0f);
|
||||||
} else {
|
} else {
|
||||||
progress = done / length;
|
progress = done / length;
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ public class MissionAdapter extends Adapter<ViewHolder> implements Handler.Callb
|
||||||
for (int i = 0; i < h.lastSpeed.length; i++) {
|
for (int i = 0; i < h.lastSpeed.length; i++) {
|
||||||
averageSpeed += h.lastSpeed[i];
|
averageSpeed += h.lastSpeed[i];
|
||||||
}
|
}
|
||||||
averageSpeed /= h.lastSpeed.length + 1f;
|
averageSpeed /= h.lastSpeed.length + 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
String speedStr = Utility.formatSpeed(averageSpeed);
|
String speedStr = Utility.formatSpeed(averageSpeed);
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class ProgressDrawable extends Drawable {
|
||||||
|
|
||||||
public ProgressDrawable() {
|
public ProgressDrawable() {
|
||||||
mMarqueeLine = null;// marquee disabled
|
mMarqueeLine = null;// marquee disabled
|
||||||
mMarqueeProgress = 0f;
|
mMarqueeProgress = 0.0f;
|
||||||
mMarqueeSize = 0;
|
mMarqueeSize = 0;
|
||||||
mMarqueeNext = 0;
|
mMarqueeNext = 0;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ public class ProgressDrawable extends Drawable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupMarquee(int width, int height) {
|
private void setupMarquee(int width, int height) {
|
||||||
mMarqueeSize = (int) ((width * 10f) / 100f);// the size is 10% of the width
|
mMarqueeSize = (int) ((width * 10.0f) / 100.0f);// the size is 10% of the width
|
||||||
|
|
||||||
mMarqueeLine.rewind();
|
mMarqueeLine.rewind();
|
||||||
mMarqueeLine.moveTo(-mMarqueeSize, -mMarqueeSize);
|
mMarqueeLine.moveTo(-mMarqueeSize, -mMarqueeSize);
|
||||||
|
|
|
@ -19,15 +19,6 @@
|
||||||
app:popupTheme="@style/ThemeOverlay.AppCompat.ActionBar"
|
app:popupTheme="@style/ThemeOverlay.AppCompat.ActionBar"
|
||||||
app:titleTextAppearance="@style/Toolbar.Title">
|
app:titleTextAppearance="@style/Toolbar.Title">
|
||||||
|
|
||||||
<Spinner
|
|
||||||
android:id="@+id/toolbar_spinner"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center_vertical|left"
|
|
||||||
android:visibility="gone"
|
|
||||||
tools:ignore="RtlHardcoded"
|
|
||||||
tools:visibility="visible"/>
|
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/toolbar_search_container"
|
android:id="@+id/toolbar_search_container"
|
||||||
layout="@layout/toolbar_search_layout"
|
layout="@layout/toolbar_search_layout"
|
||||||
|
|
Loading…
Reference in a new issue