视频播放

This commit is contained in:
nikiii 2024-06-20 22:01:09 +08:00
parent 6075a2c6d7
commit 32ea596bec
2 changed files with 37 additions and 9 deletions

View File

@ -5,8 +5,11 @@ import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.VideoView;
public class Message1Activity extends AppCompatActivity {
@ -18,21 +21,24 @@ public class Message1Activity extends AppCompatActivity {
setContentView(R.layout.activity_message1);
ImageView imageView14=findViewById(R.id.imageView14);
videoView = findViewById(R.id.videoView2);
videoView.setOnClickListener(new View.OnClickListener() {
TextView textView1=findViewById(R.id.textView39);
TextView textView2=findViewById(R.id.textView36);
textView1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
videoView.setVideoURI(Uri.parse("android.resource://"+getPackageName()+"/raw/"+R.raw.golden));
videoView.start();
}
});
// findViewById(R.id.button7).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// if (videoView.isPlaying()){
// videoView.pause();
// }
// }
// });
textView2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (videoView.isPlaying()){
videoView.pause();
}
}
});
imageView14.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View File

@ -112,6 +112,28 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView16" />
<TextView
android:id="@+id/textView39"
android:layout_width="56dp"
android:layout_height="38dp"
android:layout_marginBottom="15dp"
android:text="播放"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/imageView16"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/textView36"
android:layout_width="60dp"
android:layout_height="38dp"
android:layout_marginBottom="15dp"
android:text="暂停"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/imageView16"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>