2024-04-25 13:50:02 +02:00
2 changed files with 23 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -0,0 +1,23 @@
# VideoView
We wanted to show the different exercises in a video that anybody could replicate. For this we didn't want to implement a youtube function we wanted to have our own videos so that we don't rely on youtube. Ti start we need an emoty activity file you can create one in the android studio IDE. Then you need to head to the XML file you just created and the go to widgets and the add the VideoView element
![VideoView](VideoViewWidget.png)
If you drag that in to your activity you can edit the layout of it but it will not function directly. To Let it play videos we need to write a java code. First start by coding what you want to view.
```java
VideoView videoView = findViewById(R.id.videoView);
videoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.videofile));
```
replace the video file with the name of the video. Then you need to code the media player aswell.
```java
MediaController mediaController = new MediaController(this);
videoView.setMediaController(mediaController);
videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
videoView.start(); // Restart video on completion
}
});`
```
Since we have short videos we will have a auto replay function if you want it can go to a completion screen after the video ended.