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.
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:
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 might also like...
Android, Tech, Community
Streamlining Android Development: HeluBottomButtonSheet
If you can’t find what you need in your development toolkit, then it’s always best to build it yourself. Which is exactly what I did. My Helu utilities have gotten me through several projects. Hopefully, you might find something in my repos...
Inside STRV, Community, Events
STRV Open Air — chilling with friends along the Vltava
Can you think of a better way to cool down on these hot summer evenings than chilling along the banks of the Vltava? Neither can we, which is why we grabbed some beer, food and a bunch of friends and headed over to the Pristav recreational ...
Our Work, Tech, Progressive Web App, Frontend
How we built a Progressive Web App for Tinder
Four months. Four STRV developers. One tall order from the world’s largest dating app. No problem. The challenge: Tinder had tackled iOS, Android, Apple TV — in collaboration with STRV — and now had its sights set on web domination. This wa...