Sürekli çalışan bir videom var TEKRARLANIYOR. Bu düğmelerden birine basıldığında (birkaç düğmem var) başka bir video çalışıyor ama video bittiğinde durmuyor, tekrar ediyor. SORUN (video bittiğinde durması ve ilk videonun baştan başlaması gerekir) lütfen yardım edin.
KODLAR
package com.info.deneme4;
import androidx.appcompat.app.AppCompatActivity;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.VideoView;
public class MainActivity extends AppCompatActivity {
private Button button1, button2;
private VideoView videoView1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button1 = findViewById(R.id.button1);
button2 = findViewById(R.id.button2);
videoView1 = findViewById(R.id.videoView1);
Uri uri = Uri.parse("android.resource://com.info.deneme4/"+getPackageName()+"/"+R.raw.previewvideo);
videoView1.setVideoURI(uri);
videoView1.start();
videoView1.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.setLooping(true);
}
});
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
button1.setVisibility(View.INVISIBLE);
button2.setVisibility(View.INVISIBLE);
Uri uri = Uri.parse("android.resource://com.info.deneme4/"+getPackageName()+"/"+R.raw.video1);
videoView1.setVideoURI(uri);
videoView1.start();
videoView1.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.setLooping(true);
}
});
}
});
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
button1.setVisibility(View.INVISIBLE);
button2.setVisibility(View.INVISIBLE);
Uri uri = Uri.parse("android.resource://com.info.deneme4/"+getPackageName()+"/"+R.raw.video2);
videoView1.setVideoURI(uri);
videoView1.start();
videoView1.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.setLooping(true);
}
});
}
});
}
@Override
protected void onResume() {
super.onResume();
videoView1.start();
}
}