video will now be displayed with link from database
This commit is contained in:
@@ -40,6 +40,8 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
|
||||
private TextView exerciseShortDescriptionTextView;
|
||||
private TextView exerciseDescriptionTextView;
|
||||
|
||||
private static String exerciseVideoUrl;
|
||||
|
||||
// Some nice little messages for the user
|
||||
private static final String[] EXERCISE_NOT_FOUND_MESSAGES = new String[]{
|
||||
"Ik heb momenteel helaas wat moeite met het ophalen van oefeningen, sorry.",
|
||||
@@ -69,6 +71,7 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
|
||||
this.exerciseDescriptionTextView = findViewById(R.id.textViewDialogDescription);
|
||||
this.exerciseShortDescriptionTextView = findViewById(R.id.textViewFitnessShortDescription);
|
||||
|
||||
|
||||
// Find the VideoView by its ID
|
||||
VideoView videoView = findViewById(R.id.videoView);
|
||||
playVideo(videoView, this);
|
||||
@@ -139,6 +142,7 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
|
||||
exerciseNameTextView.setText(exercise.name);
|
||||
exerciseShortDescriptionTextView.setText(exercise.shortDescription);
|
||||
exerciseDescriptionTextView.setText(exercise.description);
|
||||
exerciseVideoUrl = exercise.videoUrl;
|
||||
onSuccessfulFetch.handle(exercise);
|
||||
}
|
||||
})).start();
|
||||
@@ -153,14 +157,7 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
|
||||
public static void playVideo(VideoView videoView, Context context) {
|
||||
// Set up the video player
|
||||
if (videoView != null) {
|
||||
Uri videoUri = Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.bicepvideo);
|
||||
videoView.setVideoURI(videoUri);
|
||||
|
||||
videoView.setOnCompletionListener(mp -> {
|
||||
// Repeat the video when it finishes playing
|
||||
videoView.start();
|
||||
});
|
||||
|
||||
videoView.setVideoPath(exerciseVideoUrl);
|
||||
videoView.start();
|
||||
} else {
|
||||
Log.e("FitnessActivity", "VideoView is null. Check your layout XML.");
|
||||
|
@@ -47,7 +47,10 @@
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="300dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_margin="50dp" />
|
||||
android:layout_marginStart="50dp"
|
||||
android:layout_marginTop="50dp"
|
||||
android:layout_marginEnd="50dp"
|
||||
android:layout_marginBottom="50dp" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
Reference in New Issue
Block a user