package com.example.fitbot;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Button;
import android.widget.MediaController;
import android.widget.VideoView;

import com.aldebaran.qi.sdk.QiContext;
import com.aldebaran.qi.sdk.builder.AnimateBuilder;
import com.aldebaran.qi.sdk.builder.AnimationBuilder;
import com.aldebaran.qi.sdk.object.actuation.Animate;
import com.aldebaran.qi.sdk.object.actuation.Animation;

public class BicepVideo extends AppCompatActivity {

//    private QiContext qiContext;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bicepvideo);
        setupButtons();
    }

    public void Video(QiContext qiContext) {
        VideoView videoView = findViewById(R.id.videoView);
        videoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.bicepvideo));

        MediaController mediaController = new MediaController(this);
        videoView.setMediaController(mediaController);
        videoView.setOnCompletionListener(mp -> videoView.start());
        videoView.start();

        Animation animation = AnimationBuilder.with(qiContext)
                .withResources(R.raw.bicepcurl)
                .build();

        Animate animate = AnimateBuilder.with(qiContext)
                .withAnimation(animation)
                .build();


        animate.async().run();

    }
    private void setupButtons() {
        Button backButton = findViewById(R.id.buttonback);
        backButton.setOnClickListener(v -> finish());

        Button completeButton = findViewById(R.id.buttoncomplete);
        completeButton.setOnClickListener(v -> {
            Intent intent = new Intent(BicepVideo.this, Completion_Screen.class);
            startActivity(intent);
        });
    }
}