B4A Library VitamioB4A - a B4A-wrapper of the vitamio-plugin (advanced videoview-library)

NOTE: This library is old and deprecated although it is still working. It was related to the very first version of Vitamio. A newer version, Vitamio 5, is available here:
An alternative is also the FFmpeg-b4a library which you can find here:


What is Vitamio

From VOV IO's web-site (vitamio VOVIO - focus on Android multimedia application):

Vitamio is a multimedia framework for all Android devices. Vitamio works like the Android's default MediaPlayer except that it includes much more powerful features. And it's absolutely free !

Network Protocols:
The following network protocols are supported for audio and video playback:

HTTP progressive streaming
HTTP live streaming (M3U8), for Android 2.1+

Media formats:
Many audio and video codecs are packed into Vitamio beside the default media format built in Android platform, some of them are listed below.


Vitamio support the display of many external and embedded subtitle formats.

Sub Station Alpha(.ssa) / Advanced Sub Station Alpha(.ass)
Matroska (.mkv) Subtitle Track

More features:
There are more wonderful features available in Vitamio.

Background playback
Multiple audio tracks support
Mutitiple subtitles support, including external and embedded ones
Processor optimization for many platforms
Buffering when streaming
Adjustable aspect ratio
Automatically text encoding detection


So VitamioB4A is a B4A-Wrapper of the Vitamio-plugin. The plugin is an Android APK which includes a collection of media demuxers, decoders, filters besides some video and audio output libraries. If the user does not have the plugin installed, the user will be prompted to download and install it from Google Play. Since the first release of the B4A-wrapper, many other features have been added and now mostly the subtitles-features of the VideoView-class are missing.

Note: android:minSdkVersion="8"

VitamioB4A allows you to play video media inside your applications. The difference from the standard Android-VideoView is that VitamioB4A supports much more formats and codecs since it is based on FFMPEG.

Why did I write this wrapper?

Well, in some of my apps which use streaming, the codec needed is not supported natively by Android. Therefore users of my apps always had to rely on external video-players apps for streaming such as DaroonPlayer, VPlayer (probably same guys that now have released the Vitamio-plugin), MX Video Player and others. Here you can download another wrapper-library of mine to use said players: http://www.b4x.com/forum/basic4andr...-waste-devices-internal-memory.html#post47646 )

While it is true that the VitamioB4A-wrapper still relies on an external solution (app), it permits though to incorporate all the streaming within my apps which means I can add OSD (onScreenDisplay) and other intereasting stuff. In addition, the player is lighter than external video-players. Other advantages are of course that it supports many more codecs and formats than what offered natively by Android.

I am a very much of a beginner in JAVA but with help of some code-examples provided on the forum by Erel and icefairy333 (thanks to both of you), I managed to write this wrapper and it seems to work pretty well. Other developers are encouraged to improve the VitamioB4A including bug-fixes, adding other classes and methods/properties. For this purpose, I am also attaching my Eclipse-project.

In this regard, I must mention some important things concerning licensing. I am not 100% sure but since the vitamio-plugin is using sources from FFMPEG, I belive sources must be published and be available for all. Therefore, I want to (and I think we must) keep this wrapper open-source. Also Vitamio has published their sources on their web-site. Here is information from their web-site what regards licenses:

Licenses (information from vitamio VOVIO - focus on Android multimedia application):

Vitamio uses several open-source projects, thanks to them.
FFmpeg provides the software codecs and demuxers. Vitamio uses code of FFmpeg (link: www.http://ffmpeg.org/)
licensed under the LGPLv2.1 (GNU Lesser General Public License v2.1 - GNU Project - Free Software Foundation) and its source can be downloaded here (http://d.vov.io/vitamio/ffmpeg.7z)

Universalchardet is the encoding detector library of Mozilla. Vitamio uses the code of universalchardet licensed under MPL to detect the encoding of subtitle texts. The original code of universalchardet is available at Mozilla
(h t t p://lxr.mozilla.org/seamonkey/source/extensions/universalchardet/ - my note: On July 5, 2012 link not working).
The code of universalchardet used by Vitamio is available here
(h t t p://d.vov.io/vitamio/universalchardet.7z. - my note: On July 5, 2012 link not working)

So if you improve/modify this wrapper using the VitamioB4A-wrapper as a base, then you are requested to post the sources here in this thread. Please include the license-information written in my original source.

Note: In case it is not clear: when I say that we should post our sources, then I mean only the source of the B4A-wrapper if someone modifies/improves it. What regards your apps, I don't see any reason why you should need to publish your source-code. However, perhaps mentioning in an About-screen that this wrapper is being used (and maybe a link to it) could not hurt in case the FFMPEG-guys want further information.

So what is the hook behind this initiave by VOV IO? Why is it free, even for commercial use? What do they have to gain?

- I really don't know. There are no adds. The only thing I read is that VOV may collect certain usage statistics.

Example usage:

The VideoView shows a media controller (disabled by default) when the user touches the view. The Completed event is raised when playback is completed.
Simple example of using VitamioB4A's VideoView:
Sub Globals
     Dim vv As VideoView
End Sub

Sub Activity_Create(FirstTime As Boolean)
         Activity.AddView(vv, 10dip, 10dip, 250dip, 250dip)
         vv.LoadVideo(File.DirRootExternal, "somefile.mp4")
End Sub

Sub vv_Complete
         Log("Playing completed")
End Sub

As you can see, it is nearly identical to the VideoView-wrapper included in the Audio-library.

In addition to the complete-event, the B4A-wrapper also includes the following events:

From SDK:
Called To indicate an error.
what - the Type of error that has occurred:
extra - an extra code, specific To the error. Typically implementation dependant.
True If the method handled the error, False If it didn't. Returning false, or not having an OnErrorListener at all, will cause the OnCompletionListener to be called.
NOTE: VitamioB4A sets default Return value To True To disable vitamio's pop-up error messages: You can handle error messages using this error-event.

From SDK:
Called To indicate an info OR a warning.
what - the Type of info OR warning.
extra - an extra code, specific To the info. Typically implementation dependant.
True If the method handled the info, False If it didn't. Returning false, or not having an OnErrorListener at all, will cause the info to be discarded.
NOTE: VitamioB4A sets default Return value To True

From SDK:
Called when the media File is ready for playback.

From SDK:
Called To update status in buffering a media stream.
percent - the percentage (0-100) of the buffer that has been filled thus far

Note: The method Play is not needed since it starts automatically.
Note2: To obtain maximum quality and to avoid pixeling, you must use the method VideoQuality and set it to 16. You can set the video-quality in the prepared-event (see sample-project).
Suggestion: If you add the VideoView to a panel, you can implement nice stuff such OSD (On Screen Display) and other functionality.

See also sample-project for more details.

The full and official API-documentation can be found at VOV IO's web-site at Generated Documentation (Untitled). Here are instead details as to methods, properties, events and permissions that were included in the VitamioB4A-wrapper. Thanks to WarWound for his script!

  • VideoView
    • android.permission.INTERNET
    • Background As Drawable
    • BufferPercentage As Int
      returns buffer percentage.
    • BufferSize As
      The buffer to fill before playback, default is 1024KB.
    • Color As
    • CurrentLayout As Int
      Returns current video-layout. This is not an official API.
    • CurrentPosition As Long
      Gets current playing position (in milliseconds).
    • Duration As Long
      Gets the video duration in milliseconds.
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • MediaControllerEnabled As
      Sets whether the media controller is enabled. It is disabled by default.
      Note that the media player gets attached to the VideoView parent.
    • Position As Long
      Gets or sets the playing position (in milliseconds). Not tested.
    • Tag As Object
    • Top As Int
    • VideoAspectRatio As Float
      Returns the aspect ratio of the video.
      the aspect ratio of the video, or 0 if there is no video,
      or the width and height is not available
    • VideoHeight As Int
      Returns the height of the video.
    • VideoWidth As Int
      Returns the width of the video.
    • Visible As Boolean
    • Width As Int
    • BringToFront
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • IsPlaying As Boolean
      Tests whether the video is currently playing.
    • LoadVideo (Dir As String, FileName As String)
      Loads a video file and prepares it for playing.
      It is not possible to load files from the assets folder.
      You can pass "http" to the Dir parameter and then a full URL (including http) to the FileName.
      In this case the online video will be streamed. If you want for instance stream using MMS,
      you must still pass "http" to the Dir parameter.
      Note: There is no need to add the INTERNET permission for this to work since it is already
      included in the B4A wrapper-library.
      Note2: No need to use the method Play - the streaming will start anyway.
      Note3: Depending on the URL, you may or not need to URL-encode before passing on the URL.
    • Pause
      Pauses the playback.
    • Play
      Starts or resumes playing.
    • RemoveView
    • RequestFocus As Boolean
    • Resume
      Resumes the playback. Perhaps same as Play (not tested).
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • Stop
      Stops the playback.
    • VideoLayout (vLayout As Int, vAspectRatio As Float)
      Set the display options. Default is VIDEO_LAYOUT_ZOOM or 3.
      aspectRatio - video aspect ratio, will auto detect if 0.
    • VideoQuality (vQuality As Int)
      Set the quality when playing video. If there is too much lag, try VIDEOQUALITY_LOW.
      If there is too much pixeling, set the value to VIDEOQUALITY_HIGH
      I would suggest always to use VIDEOQUALITY_HIGH or VIDEOQUALITY_MEDIUM
      (most modern android-devices can cope with higher settings)
      Note that default value is VIDEOQUALITY_LOW.
    • canSeekBackward As Boolean
      verifies if the media can seek backward.
    • canSeekForward As Boolean
      verifies if the media can seek forward.
    • getAudioTrackMap (encoding As String) As HashMap
      Get the audio tracks embedded in the movie (e.g. "English", 3).
      encoding - the encoding to format String, will detect it if null
      Map of track name and track number
    • isBuffering As Boolean
      Checks whether the buffer is filled or not.
    • isValid As Boolean
      Checks (what??) is valid or not. To test.
    • obtainAudioTrack As Int
      Get the audio track number in playback
    • seekTo (msec As Long)
      Seeks to specified time position.
      msec - the offset in milliseconds from the start to seek to
      java.lang.IllegalStateException - if the internal player engine has not been initialized
    • selectAudioTrack (audioIndex As Int)
      Set the audio track to play, must be in the result of getAudioTrackMap(String)
      audioIndex - the track number
    • setVolume (leftVolume As Float, rightVolume As Float)
      sets the volume. No idea about ranges to use (perhaps 1 to 15). To test.
      Might be better to use Phone-library in B4A.
    • toString As String

Finally, attached to this post you can find:

-vitamiob4a*.zip (libraries necessary - add in your extra-library folder)
-vitamiob4a_demo*.zip (sample-project)
-SourceVitamiob4a*.zip (Eclipse source-code) - not needed for using the Vitamo-plugin. Only for developers who would like to enhance the wrapper.

Good luck!

UPDATE July 8, 2012:
-added support for seekTo, canSeekBackward and other related methods/properties
-added support for audio-track handling (for instance with videos/streams having original language plus additional languages). When changing audio-track and to avoid problems with syncing between video and audio, you must first save the current-position, then set the new audio-track and then use seekTo. I got it working that way.

UPDATE July 14, 2012:
-added support for some other missing methods/properties
-added other events (error, info, prepared, buffering). See notes above and sample-project for usage.
-Vitamio's pop-up messages are now disabled

Next I will try to add support for subtitles and see if I can get it to work


  • vitamiob4a_1_05.zip
    61.9 KB · Views: 1,541
  • VitamioB4ADemo1_05.zip
    8 KB · Views: 1,321
  • SourceVitamiob4a_1_05.zip
    13.9 KB · Views: 992
Last edited:


Active Member
Licensed User
Longtime User
I have tried the following:
- download the source of your b4a vitamio wrapper library
- download the source code of the up-to-date vitamio library (from https://github.com/yixia/VitamioBundle)
- build an updated vitamio.jar file based on the library
- rebuild the b4a wrapper library to include the updated vitamio library (together with lib files), in order not to require installtion of vitamio plugin.

Running the b4a demo everything seems to be ok (no errors at all) except the fact that ... nothing can be seen or heard.

For sure I'm doing something wrong, but I don't know what..



Licensed User
Longtime User
I meant of course as a "free app" and then I think you as a developer can be considered an "individual". However if you add ads to your app (and make money), then I don't know... In either case, everything is very unclear and I suggest anyone using Vitamio (from version 4) should contact the publisher of the Vitamio-library to sort it out. However, the version posted in this thread should be OK since it only wraps version 1.

I don't know how it is around the world, but in Europe you cannot publish your apps (except freewares) without being an enterprise.

Unsure about this...in Italy you can be an individual/private person (without having a registered VAT-Number) and you can license your work to third parties. This is because that your software falls under the Copyright Act and in many bilateral tax-regulations the Copyright-Act is included. However, in this case, what regards Vitamio and its license, I think a similar scenario would be considered as an "enterprise". However, as mentioned, anyone who has doubts should write to the publisher of Vitamio.


Active Member
Licensed User
Longtime User
Hi Dan,

Please note that my version of the Vitamio-wrapper covered, I believe, only the first version of Vitamio. As you say, Vitamio is currently at version 4 and Warwound has made an updated wrapper of Vitamio which you can find in this thread:

Video View Fullscreen And On Top On Ouya

Maybe that updated version can be of help.
This update is working, so I just have to recompile ffmpeg and build libarm.so with opus support.



Licensed User
Longtime User
I meant of course as a "free app" and then I think you as a developer can be considered an "individual". However if you add ads to your app (and make money), then I don't know...

When I looked at the rules recently, I saw they were defined by the European Union, so I'm sure at 90% that you cannot earn money in Europe with a product of your own without being an enterprise (the product has been created to earn money, so it's a commercial product from a legal point of view), but I'm not a lawyer.

Unsure about this...in Italy you can be an individual/private person (without having a registered VAT-Number) and you can license your work to third parties.

In France, selling your work to a third party is also a different matter if you sell the rights (to distribute, to modify, to use, to resell, etc.) and, in this case, you do not need to be an enterprise. On the contrary, if you sell a copy of your software, you sell not a right but a product and it's a commercial act. I don't think it's different in Italy.


Licensed User
Longtime User
These are not easy subjects and as you say, many times a lawyer/tax-consultant is needed but very often they, too, have different opinions because not always the regulations are 100% clear and they can be interpreted differently :mad:

However, what you are saying about those rules defined by the European Union have gone unnoticed by me. Any chance you have a link so I may read further? Thanks.

I am aware we may be OT here but it is an interesting point :)


Licensed User
Longtime User
However, what you are saying about those rules defined by the European Union have gone unnoticed by me. Any chance you have a link so I may read further? Thanks.
I recently gave a link in the french section of this forum but the text is in french. EDIT: all the links that I find in english are about selling on eBay, which is a different case. You should try to find some information in italian. Until now, I saw that the legal rule is the same in the UK (and they have apparently the same special status as we have in France, they call that a "sole-trader").
Last edited:


Active Member
Licensed User
Longtime User
This update is working, so I just have to recompile ffmpeg and build libarm.so with opus support.


Tried for weeks without success. I've succeed at the end to build libffmpeg.so file with opus support, but including it in the libarm.so package, as described on Vitamio site does not work. For any file I try to play I get an error like:
Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 22612 (tamiobundledemo)

Trying the last libarm.so from VItamio site I get no playback at all, without any error.

There is any other possiblity to play an opus/ogg network stream in B4A?



Active Member
Licensed User
Longtime User
How do you use the built-in constants for video quality, zoom mode etc. (e.g. VIDEOQUALITY_HIGH). Are these defined in the library?


Active Member
Licensed User
Longtime User
Is there any way to play 2 videos simultaneously using vitamio...?????

I have tried it but som glitches are coming....please someone help...


Licensed User
Longtime User
Last edited:


Active Member
Licensed User
Longtime User
I have tried this for play DVR cam.
My DVR have 8 cam.
Video start well (I can see image) but it's locked and does not go forward.
Is there a way for solve it?



Well-Known Member
Licensed User
Longtime User
HI, trying the example project with this B4A gives this error?

B4A version 4.30
Parsing code.                           0.00
Compiling code.                         0.01
ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code.                 0.00
Generating R file.                      0.03
Compiling generated Java code.          Error
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Error occurred during initialization of VM
Could not reserve enough space for object heap

Whats the problem with this?




Active Member
Licensed User
Longtime User
I run you demo the i got an error "Unfortunately, Vitamiodemo has stopped"

Any advice?

Asus Zenfone 5 (Kitkat)


Licensed User
Longtime User
You would need to download the html-source and then parse the source to obtain the links (and store them somewhere - maybe a list) and then pass a link (one a time).

BTW: this is an old library. See my earlier post about alternative libraries. You could also try the new (experimental) VLC-wrapper. Just search the forum for "vlcb4a". Even with these newer libraries, you still need to handle the links as mentioned above.