I have just finished a project where I use a webwiew for video playback. Now I am asked to replace the webview part with a custom player. The player should be capable to handle HLS.
If I use VideoView and MediaController, I can play live stream. But unfortunately, the MediaController has its own controls. I want my own controls and thats where I am stuck.
So far I tried:
I have been in almost every thread on Stackoverflow regarding custom media player but couldnt find information to get me started.
Is it possible to create a custom media player class without using NDK?
If someone knows how to create a custom media player class, please help me.
MediaPlayer. This class is the primary API for playing sound and video. AudioManager. This class manages audio sources and audio output on a device.
android.media.MediaPlayer. MediaPlayer class can be used to control playback of audio/video files and streams.
You could use VideoView on it's own and call it's methods to control playback such as start(), stopPlayback(), pause(), resume(), seekTo() etc. (See class reference here: http://developer.android.com/reference/android/widget/VideoView.html)
Just create your on-screen controls however you want (buttons/images) and bind your playback control code code to their events.
You will also want to disable the inbuilt VideoView controls by removing the touchable property in the layout.xml...
<VideoView
android:id="@+id/myVideoView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="false" >
I recommend using VLC as it support nearly all video formats, and of-course streaming. You can try to pick up on a pre-compiled libvlc AAR file from github or compile VLC by yourself: AndroidCompile.
Example of pre-compiled libvlc you can find here: https://github.com/mrmaffen/vlc-android-sdk
This is not the latest version by I believe it will be good for your needs. Next you will will need to create the code around the library. Example: https://github.com/Ivshti/libvlc-android-sample
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With