mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-06-09 06:40:07 +03: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 FragmentSlideMediaBinding binding;
|
||||||
private SlidrInterface slidrInterface;
|
private SlidrInterface slidrInterface;
|
||||||
|
|
||||||
|
private boolean visible = false;
|
||||||
|
|
||||||
public FragmentMedia() {
|
public FragmentMedia() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
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) {
|
private void loadVideo(String url, String type) {
|
||||||
if (binding == null || !isAdded() || getActivity() == null || url == null) {
|
if (binding == null || !isAdded() || getActivity() == null || url == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -267,7 +271,7 @@ public class FragmentMedia extends Fragment {
|
||||||
binding.mediaPicture.setVisibility(View.GONE);
|
binding.mediaPicture.setVisibility(View.GONE);
|
||||||
player.setMediaSource(videoSource);
|
player.setMediaSource(videoSource);
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setPlayWhenReady(true);
|
player.setPlayWhenReady(visible);
|
||||||
player.addListener(new Player.Listener() {
|
player.addListener(new Player.Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerError(@NonNull PlaybackException error) {
|
public void onPlayerError(@NonNull PlaybackException error) {
|
||||||
|
@ -301,6 +305,7 @@ public class FragmentMedia extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
visible = false;
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.setPlayWhenReady(false);
|
player.setPlayWhenReady(false);
|
||||||
}
|
}
|
||||||
|
@ -318,9 +323,11 @@ public class FragmentMedia extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
visible = true;
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.setPlayWhenReady(true);
|
player.setPlayWhenReady(true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue