Reputation: 22527
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.
Upvotes: 7
Views: 2329
Reputation: 52
This may not help but you can I know for music players you just create java class, and create your mediaplayer, name public your name extends mediaplayer. Refer to Vanilla music github, search for vanilla music player and copy class to your app and Change a few things like requesting audio effects, for equaliser I put custom stuff in onprepared for my class, and incompletetion listener, then simply change the Mediaplayer player = new Mediaplayer, with For e.g. my name I used from vanilla mediaplayer so then say VanillaMediaplayer player or variable = new VanillaMediaplayer it helps also do less work, then use as you wish, hope this helps.
Upvotes: 1
Reputation: 2556
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
Upvotes: 1
Reputation: 171
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" >
Upvotes: 1