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