---
title: 'Streamlining Android Development 1: HELU VideoView'
url: 'https://helu.cz/blog/streamlining-android-helu-videoview'
markdown: 'https://helu.cz/blog/streamlining-android-helu-videoview.md'
date: '2019-01-01'
description: 'When we can’t find the tools we need to make the development process run smoother, many of us end up creating them ourselves. Today I will show you how to use the HELUVideoView library to easily create and control videos in your app. Software developers are'
taxonomy:
  category:
    - blog
  tag:
    - How-To
    - Android
  archives_month:
    - jan_2019
  archives_year:
    - '2019'
---

# Streamlining Android Development 1: HELU VideoView

Software developers are always on the lookout for ways to streamline their jobs. When we can’t find the tools we need to make the development process run smoother, many of us end up creating them ourselves. I’ve developed a repository of various utility classes that has helped me tackle several projects. This short-and-sweet blog post series will introduce you to the ins and outs of my HELU utilities aimed at making Android development easier.

![](https://helu.cz/user/pages/02.blog/streamlining-android-helu-videoview/heluvideoview_1.jpg#center)

Today I will show you how to use the **HELUVideoView** library to easily create and control videos in your app. First of all, I would like to point out that HELUVideoView has only basic control options, like Play/Pause, Mute and SeekBar. It can only display one simple video to the user. It’s not meant to be a complex media player.

If you ask what HELUVideoView can offer to you that VideoView cannot, the answer is simple: HELUVideoView offers more convenient methods that can be used and is simpler to set up and use, without losing direct access to MediaPlayer. Some of those helpful methods are: `seekToBeginning()`, `playFromBeginning()`, `setOnStateChangeListener()`, etc.. You also have better control over video looping, and autoplay/pause when attaching and detaching view. This can be super helpful when your activity/fragment lose focus for some reason. In my opinion, the main advantage of this library is that you have complete control over what the player looks like. You can create your own buttons and place them anywhere you like, inside or outside the player view.

Let’s get down to examples. Start by adding the HELUVideoView library to your Gradle file:

```
implementation "cz.helu.android:heluvideoview:2.0.0"
```

Now you have two options. They are pretty similar as they both use the `Builder` class provided by the HELUVideoView library. The first one is creating the view manually in your java/kotlin source using the `Builder` class. The second one is creating the view inside you XML layout file and then just initializing it from the Builder class using the `initFromBuilder()` method.

Here’s an example of what it could look like in both cases:

```
var builder = HeluVideoView.Builder(context)
    .withScalingMode(HeluVideoView.ScaleType.SCALE_TO_FIT_VIDEO)
    .withVideoUrl("Some Video URL")
    .withPlayView(playButtonView)
    .withPauseView(pauseButtonView)

// In first case we would just build the view
var videoView = builder.build()

// In second case we would init already existing view from builder
findViewById<HeluVideoView>(R.id.video_view).initFromBuilder(builder)
```

As you can see, we set `ScaleType.SCALE_TO_FIT_VIDEO`, which will resize the HELUVideoView Height to fit the video size. We also set play and pause buttons views. HELUVideoView will now use them and automatically set their visibility and OnClickListeners based on the MediaPlayer state.

The next cool thing is that we can simply set any SeekBar view to HELUVideoView, and it will automatically update its progress and also set all necessary listeners, so the video view can be controlled by it.

Another interesting part is the `withPauseOnVisibilityChange()` builder method, which will make sure the video is automatically paused when the view visibility changes. This is set to true by default. You can see how this works in the video below:

![](https://helu.cz/user/pages/02.blog/streamlining-android-helu-videoview/heluvideoview_2.gif#center)

Setting `withAttachViewPolicy()` can also come in handy. We have three options here: continue, pause and start over. They will tell HELUVideoView what should happen when the player view is attached to any Layout. This can happen for example in RecyclerView.

I hope you like my HELUVideoView library. You can see all methods and examples [here](https://github.com/Tuxilero/HELU-Utils). If you have any feature requests or issues do not hesitate to contact me.

 [ Previous Post](https://helu.cz/blog/linux-update-or-repair-your-grub) [Next Post ](https://helu.cz/blog/streamlining-android-helu-bottom-button-sheet)

---

#### Popular Tags

  [How-To](https://helu.cz/blog/tag:How-To) [DIY](https://helu.cz/blog/tag:DIY) [Android](https://helu.cz/blog/tag:Android) [Boosted](https://helu.cz/blog/tag:Boosted) [Scooter](https://helu.cz/blog/tag:Scooter) [Battery](https://helu.cz/blog/tag:Battery) [Repair](https://helu.cz/blog/tag:Repair) [Linux](https://helu.cz/blog/tag:Linux) [Laser](https://helu.cz/blog/tag:Laser) [Engraving](https://helu.cz/blog/tag:Engraving) [Painting](https://helu.cz/blog/tag:Painting) [Art](https://helu.cz/blog/tag:Art) [GRUB](https://helu.cz/blog/tag:GRUB) [Bluetooth](https://helu.cz/blog/tag:Bluetooth) [Windows 10](https://helu.cz/blog/tag:Windows%2010) [Fix](https://helu.cz/blog/tag:Fix) 

#### Related Posts

- 100 

     [Streamlining Android Development 4: HELU Parallax View](https://helu.cz/blog/streamlining-android-helu-parallax-view "Streamlining Android Development 4: HELU Parallax View")
- 100 

     [Streamlining Android Development 3: HELU Collapsing Tab Bar](https://helu.cz/blog/streamlining-android-helu-collapsing-tab-bar "Streamlining Android Development 3: HELU Collapsing Tab Bar")
- 75 

     [Streamlining Android Development 5: Splitting Android resources like a pro!](https://helu.cz/blog/splitting-android-resources-like-a-pro "Streamlining Android Development 5: Splitting Android resources like a pro!")
- 75 

     [Streamlining Android Development 2: HELU Bottom Button Sheet](https://helu.cz/blog/streamlining-android-helu-bottom-button-sheet "Streamlining Android Development 2: HELU Bottom Button Sheet")
- 50 

     [Boosted Rev: Battery Cells Replace - Part 4](https://helu.cz/blog/boosted-rev-battery-cells-replace-part-4 "Boosted Rev: Battery Cells Replace - Part 4")

#### Archives

- [ 4 July 2022 ](https://helu.cz/blog/archives_month:jul_2022)
- [ 1 April 2021 ](https://helu.cz/blog/archives_month:apr_2021)
- [ 1 November 2020 ](https://helu.cz/blog/archives_month:nov_2020)
- [ 1 July 2020 ](https://helu.cz/blog/archives_month:jul_2020)
- [ 1 September 2019 ](https://helu.cz/blog/archives_month:sep_2019)
- [ 4 January 2019 ](https://helu.cz/blog/archives_month:jan_2019)
- [ 1 February 2014 ](https://helu.cz/blog/archives_month:feb_2014)

---

## Navigation

- Parent: [Blog](https://helu.cz/blog.md)
- Previous: [Streamlining Android Development 2: HELU Bottom Button Sheet](https://helu.cz/blog/streamlining-android-helu-bottom-button-sheet.md)
- Next: [Linux Cookbook 1: Update or Repair your GRUB installation](https://helu.cz/blog/linux-update-or-repair-your-grub.md)
