mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Fix - Videos are played simultaneously
This commit is contained in:
parent
870eeeb834
commit
e06222733c
1 changed files with 8 additions and 1 deletions
|
@ -71,9 +71,12 @@ public class FragmentMedia extends Fragment {
|
|||
private FragmentSlideMediaBinding binding;
|
||||
private SlidrInterface slidrInterface;
|
||||
|
||||
private boolean visible = false;
|
||||
|
||||
public FragmentMedia() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
|
@ -236,6 +239,7 @@ public class FragmentMedia extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private void loadVideo(String url, String type) {
|
||||
if (binding == null || !isAdded() || getActivity() == null || url == null) {
|
||||
return;
|
||||
|
@ -267,7 +271,7 @@ public class FragmentMedia extends Fragment {
|
|||
binding.mediaPicture.setVisibility(View.GONE);
|
||||
player.setMediaSource(videoSource);
|
||||
player.prepare();
|
||||
player.setPlayWhenReady(true);
|
||||
player.setPlayWhenReady(visible);
|
||||
player.addListener(new Player.Listener() {
|
||||
@Override
|
||||
public void onPlayerError(@NonNull PlaybackException error) {
|
||||
|
@ -301,6 +305,7 @@ public class FragmentMedia extends Fragment {
|
|||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
visible = false;
|
||||
if (player != null) {
|
||||
player.setPlayWhenReady(false);
|
||||
}
|
||||
|
@ -318,9 +323,11 @@ public class FragmentMedia extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
visible = true;
|
||||
if (player != null) {
|
||||
player.setPlayWhenReady(true);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue