use of com.odysee.app.MainActivity in project odysee-android by OdyseeTeam.
the class FileViewFragment method scheduleElapsedPlayback.
private void scheduleElapsedPlayback() {
if (!elapsedPlaybackScheduled) {
elapsedPlaybackScheduler = Executors.newSingleThreadScheduledExecutor();
elapsedPlaybackScheduler.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
if (MainActivity.appPlayer != null) {
elapsedDuration = MainActivity.appPlayer.getCurrentPosition();
int elapsedSeconds = Double.valueOf(elapsedDuration / 1000.0).intValue();
if (elapsedDuration > 0 && elapsedSeconds % 5 == 0 && elapsedSeconds != lastPositionSaved) {
// save playback position every 5 seconds
savePlaybackPosition();
lastPositionSaved = elapsedSeconds;
}
renderElapsedDuration();
}
}
});
}
}
}, 0, 500, TimeUnit.MILLISECONDS);
elapsedPlaybackScheduled = true;
}
}
use of com.odysee.app.MainActivity in project odysee-android by OdyseeTeam.
the class FileViewFragment method setPlaybackSpeedToDefault.
private void setPlaybackSpeedToDefault() {
Context context = getContext();
if (context instanceof MainActivity) {
int speed = ((MainActivity) context).playbackDefaultSpeed();
setPlaybackSpeed(MainActivity.appPlayer, speed);
}
}
use of com.odysee.app.MainActivity in project odysee-android by OdyseeTeam.
the class FileViewFragment method disableFullScreenMode.
@SuppressLint("SourceLockedOrientationActivity")
private void disableFullScreenMode() {
Context context = getContext();
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
View root = getView();
if (root != null) {
RelativeLayout mediaContainer = root.findViewById(R.id.file_view_media_container);
View exoplayerContainer = root.findViewById(R.id.file_view_exoplayer_container);
((ViewGroup) exoplayerContainer.getParent()).removeView(exoplayerContainer);
mediaContainer.addView(exoplayerContainer);
View playerView = root.findViewById(R.id.file_view_exoplayer_view);
((ImageView) playerView.findViewById(R.id.player_image_full_screen_toggle)).setImageResource(R.drawable.ic_fullscreen);
exoplayerContainer.setPadding(0, 0, 0, 0);
activity.exitFullScreenMode();
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}
}
}
use of com.odysee.app.MainActivity in project odysee-android by OdyseeTeam.
the class FileViewFragment method enableFullScreenMode.
@SuppressLint("SourceLockedOrientationActivity")
private void enableFullScreenMode() {
Context context = getContext();
if (context instanceof MainActivity) {
View root = getView();
if (root != null) {
ConstraintLayout globalLayout = root.findViewById(R.id.file_view_global_layout);
View exoplayerContainer = root.findViewById(R.id.file_view_exoplayer_container);
((ViewGroup) exoplayerContainer.getParent()).removeView(exoplayerContainer);
globalLayout.addView(exoplayerContainer);
View playerView = root.findViewById(R.id.file_view_exoplayer_view);
((ImageView) playerView.findViewById(R.id.player_image_full_screen_toggle)).setImageResource(R.drawable.ic_fullscreen_exit);
MainActivity activity = (MainActivity) context;
activity.enterFullScreenMode();
exoplayerContainer.setPadding(0, 0, 0, 0);
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
}
}
}
use of com.odysee.app.MainActivity in project odysee-android by OdyseeTeam.
the class FileViewFragment method setPlayerQualityToDefault.
private void setPlayerQualityToDefault() {
Context context = getContext();
if (context instanceof MainActivity) {
boolean isOnMobileNetwork = isMeteredNetwork(context);
int quality = isOnMobileNetwork ? ((MainActivity) context).mobileDefaultQuality() : ((MainActivity) context).wifiDefaultQuality();
setPlayerQuality(MainActivity.appPlayer, quality);
}
}
Aggregations