Streamlining Android Development: HeluVideoView

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.

Player

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

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 start by adding this library to Gradle file:

implementation 'cz.helu.android:heluvideoview:1.2.0'

Now add the HeluVideoView to your layout file, then create the views programmatically or inside the layout file. After that just fill the Builder class, and you are done.

var heluVideoView = HeluVideoView.Builder(context)
	.withScalingMode(HeluVideoView.ScaleType.SCALE_TO_FIT_VIDEO)
	.withVideoUrl("Some Video URL")
	.withPlayView(playButtonView)
	.withSeekBarView(seekBarView)
	.build()

If you ask what HeluVideoView can offer to you that VideoView cannot, then 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, auto play/pause, when attaching and detaching view. This can be super helpful when your activity/fragment lose focus for some reason.

You can see all methods and examples here or go to STRV.io, STRV's new open source library hub.

Github Source Code

Share Article
Lukáš Hermann

Lukáš Hermann

Lukas is STRV's Android developer based in the Brno office. He loves computers, games, and programming is his passion.

You might also like...