Fix by Alper

Signed-off-by: Jonas Mayer <jonas.a.mayer@gmx.net>
This commit is contained in:
Jonas Mayer 2024-04-02 10:42:58 +02:00 committed by Alper Öztürk
parent e13d243ab0
commit 7615d8e09f

View file

@ -46,6 +46,7 @@ import com.nextcloud.client.network.ClientFactory;
import com.nextcloud.common.NextcloudClient;
import com.nextcloud.ui.fileactions.FileActionsBottomSheet;
import com.nextcloud.utils.extensions.BundleExtensionsKt;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.databinding.FragmentPreviewMediaBinding;
import com.owncloud.android.datamodel.OCFile;
@ -324,6 +325,15 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
public void onStart() {
super.onStart();
Log_OC.v(TAG, "onStart");
@NonNull Context context;
if (getContext() != null) {
context = getContext();
} else {
context = MainApp.getAppContext();
}
OCFile file = getFile();
if (file != null) {
// bind to any existing player
@ -348,9 +358,9 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
try {
nextcloudClient = clientFactory.createNextcloudClient(accountManager.getUser());
handler.post(() -> {
exoPlayer = NextcloudExoPlayer.createNextcloudExoplayer(requireContext(), nextcloudClient);
exoPlayer = NextcloudExoPlayer.createNextcloudExoplayer(context, nextcloudClient);
exoPlayer.addListener(new ExoplayerListener(requireContext(), binding.exoplayerView, exoPlayer, () -> {
exoPlayer.addListener(new ExoplayerListener(context, binding.exoplayerView, exoPlayer, () -> {
goBackToLivePhoto();
return null;
}));