I'm currently immersed in a project that involves a series of exercises. When I select an exercise, it takes me to another page where I can watch a video demonstration of that particular exercise. Here's what I have implemented so far:
This is my home.html:
<ion-card *ngIf="oefening1" (click)="navigate(oefening1, oefening2, oefening3, oefening4)">
<img src="assets/img/{{ oefening1 }}.jpg"/>
<ion-card-content>
<ion-card-title>{{ oefening1 }}</ion-card-title>
<p>Sets: {{ set1 }}</p>
<p>Reps: {{ rep1 }}</p>
</ion-card-content>
<ion-card *ngIf="oefening2" (click)="navigate(oefening2, oefening1, oefening3, oefening4)">
<img src="assets/img/{{ oefening2 }}.jpg"/>
<ion-card-content>
<ion-card-title>{{ oefening2 }}</ion-card-title>
<p>Setjes: {{ set2 }}</p>
<p>Herhalingen: {{ rep2 }}</p>
</ion-card-content>
</ion-card>
This is the navigate function in home.ts:
navigate(exercise, exercise2, exercise3, exercise4){
this.navCtrl.push(ExercisePage, {
clickedExercise: exercise,
secondExercise: exercise2,
thirdExercise: exercise3,
fourthExercise: exercise4
});
}
This is my exercise.html:
<ion-content padding overflow-scroll="true">
<ion-grid>
<ion-row>
<ion-col col-12>
<div (click)="playVid()" padding-bottom>
<img *ngIf="fullPath" [src]="fullPath"/>
</div>
<div text-center>
<button ion-button block [disabled]="!disabledBtn">Block Button</button>
<button ion-button round (click)="nextExercise()">Complete</button>
</div>
</ion-col>
</ion-row>
</ion-grid>
</ion-content>
And here's the exercise.ts:
export class ExercisePage {
public clickedExercise: any;
public secondExercise: any;
public thirdExercise: any;
public fourthExercise: any;
public fullPath: string;
public disabledBtn: boolean;
constructor(public navCtrl: NavController, private streamingMedia: StreamingMedia, public params:NavParams) {
this.clickedExercise = params.get("clickedExercise");
this.secondExercise = params.get("secondExercise");
this.thirdExercise = params.get("thirdExercise");
this.fourthExercise = params.get("fourthExercise");
this.disabledBtn = false;
}
playVid(){
console.log('video completed');
setTimeout(() => {
this.disabledBtn = true;
}, 10000);
// Playing a video.
let options: StreamingVideoOptions = {
successCallback: () => { console.log('Video played') },
errorCallback: (e) => { console.log('Error streaming') },
orientation: 'portrait'
};
this.streamingMedia.playVideo('http://www.sylvanreinieren.com/fysioWebapp/videos/'+ this.clickedExercise + '.mp4', options);
}
ionViewWillEnter() {
this.fullPath = "assets/img/" + this.clickedExercise + ".jpg";
// console.log('secondExercise:',this.secondExercise, 'ThirdExercise: ', this.thirdExercise, 'Fourth: ', this.fourthExercise);
}
nextExercise(){
this.clickedExercise = this.secondExercise;
this.secondExercise = this.thirdExercise;
this.thirdExercise = this.fourthExercise;
this.navCtrl.push(ExercisePage, {
clickedExercise: this.secondExercise,
secondExercise: this.thirdExercise,
thirdExercise: this.fourthExercise
});
console.log('nextExercise', this.clickedExercise);
}
}
Essentially, I aim to display the next exercise when the "Next" button is clicked, progressing through each exercise in turn and returning to the home page once all exercises are completed. Unfortunately, it seems to be skipping the second exercise. Any suggestions on how to resolve this issue would be greatly appreciated.