B4A Library Vitamio 5 (Version 5.2.3)

VITAMIO 5

a B4A-wrapper of Vitamio5 (version 5.2.3 of January 7, 2018)

This is an update of Vitamio and wraps version 5.2.3 of Vitamio. The original java-sources can be downloaded here.

All donators will receive an e-mail with download instructions.

New:
-The text-relocations problem with ffmpeg has now been resolved. You can now target the most recent versions of Android with the included platforms. I tried SDK 26 and it works fine on x86 and Arm.
-Support for arm64-v8a was also added in addition to armeabi-v7a and x86.
-Fixed a bug in the original Vitamio java-sources where the MediaController would not show correctly on SDK 24.

Unfortunately, previous versions 5.0.0, 5.0.2 and the latest version (5.2.3) of Vitamio seem to have been developed and compiled by Vitamio in a very hasty way without double-checking if things are working or not. I wrote a sample app in Android Studio and encountered two problems:

1) subtitles do not seem to work.
2) if you have a stream containing multiple audio-tracks, then changing from one format/language to another (for instance from English to French), the audio will be muted after the change.

Said problems have not yet been fixed by the Vitamio team despite developers reporting said issues. I have therefore removed the related properties, events and methods from the B4A-wrapper. If they fix them in the future with a new release, I will of course add them back to the wrapper.

However, what regards subtitle-support, I implemented another solution and I have added it to the wrapper so you can show subtitles. You can also check which character encoding to apply to the subtitles. Various subtitle-formats are supported but I have only verified the srt-format. In the demo-project, I have included some sample code to show you how to use subtitles.

Apart from what mentioned above, all the rest should work just fine.

Previous new stuff:
- a new layout named "VIDEO_LAYOUT_FIT_PARENT" was added.
- a new method to set Hardware Acceleration was added.
- a new method which permits amplifying audio.
- the method for adding headers is now called SetVideoPathWithHeaders
- a new method which lets you set Audio and Video Options (SetAVOptions)
- the methods CanPause, CanSeekBackward and CanSeekForward were removed by Vitamio in this version for unknown reasons. Probably due to a previous reported bug.
- the platforms now supported are: armeabi-v7a and x86
- added my own implementation for subtitles
- added/exposed a method to take a screenshot of the video

So if you do not use audio-tracks, Vitamio5 (version 5.2.3) should be fine.

Some other notes:
- To use Vitamio5, you need to use the #AdditionalRes attribute in your project. Please see the sample project for usage (basically you replace the path I am using in my sample project with the path to your folder where you saved the supplied res-folders on your PC).
- You need at least B4A v3.20 or later to compile your app
- I am only providing a B4A-wrapper to let you use Vitamio. Check the Vitamio site for any licensing issues.

Here is a summary of events, properties and methods available in this Vitamio5 wrapper.

vitamio5
Author:
Martin Pearman / Mikael Osterhed
Version: 5.23

  • Methods:
    • deSync
      Stop syncing the subtitle object with the VideoView
    • sync (textObject As TimedTextObject)
      Start syncing a subtitle object with the VideoView
      textObject: The subtitle to load
    Properties:
    • Delay As Int
      Get how often in milliseconds to refresh the subtitles
    • SubView As TextView
      Get the TextView to display subtitles on.
    • View As VideoView [read only]
      Get the VideoView to sync the subtitles with

  • Methods:
    • cancel As Boolean
    • run
    • scheduledExecutionTime As Long

  • Methods:
    • runOnUiThread (r As Runnable)
  • Vitamio_MediaController
    Events:
    • Hidden
    • Shown
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • Hide
    • 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
    • IsShowing As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetAnchorView (View1 As View)
      Set the View that acts as the anchor for the controller view.
      This can for example be a VideoView, or your Activity's main view.
    • SetAnimationStyle (AnimationStyle As Int)
      Set the animation style resource for this controller.
      If the controller is showing, calling this method will take effect only the next time the controller is shown.
      Set to -1 for the default animation, 0 for no animation, or a resource identifier for an explicit animation.
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetFileName (FileName As String)
      Set the content of the TextView that displays the filename of the playing video.
    • SetInfoView (OutlineTextView1 As OutlineTextView)
      Set the View to hold some information when interact with the MediaController.
      This method is currently of little use, the Vitamio OutlineTextView needs to be wrapped into this library in order to use this method.
      Wrapping OutlineTextView into this library is planned as a future update.
    • SetInstantSeeking (SeekWhenDragging As Boolean)
      Control the action when the seekbar is dragged by user.
      If True the media will seek periodically when the seekbar is dragged.
      Default value is True.
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • Show
      Show the controller on screen.
      It will go away automatically after a default 3000 milliseconds of inactivity.
    • Show2 (Timeout As Int)
      Show the controller on screen.
      It will go away automatically after 'Timeout' milliseconds of inactivity.
      Use 0 to show the controller until hide() is called.
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • Enabled As Boolean
    • Parent As Object [read only]
    • Tag As Object
    • Visible As Boolean
  • Vitamio_OutlineTextView
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • Initialize
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetShadowLayer (Radius As Float, DX As Float, DY As Float, Color As Int)
    • SetText (Text As String)
    • SetTextColor (Color As Int)
    • SetTextSize (Size As Float)
    • SetTypeface (Typeface1 As Typeface)
    • SetTypeface2 (Typeface1 As Typeface, Style As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Parent As Object [read only]
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int
  • Vitamio_Subtitles
    Methods:
    • Initialize (view As VideoView, subView As TextView)
    • IsInitialized As Boolean
    • deSyncSubtitles
      Stop syncing the subtitle object with the VideoView
    • guessEncodingFromFile (subtitlePath As String) As String
      Get/Guess character-encoding format from subitle file.
      example:
      guessEncodingFromFile(File.Combine(File.DirRootExternal, "subfile.srt"))
    • setSubtitleFile (SubtitlePath As String, encoding As String)
      Set the subtitle-file to use. Supported formats are:
      .srt, .ass, .ssa, .stl, .xml (only .srt format has been tested)
      example:
      setSubtitleFile(File.Combine(File.DirRootExternal,"subfile.srt"),"Windows-1252")
      Tip: use the included method guessEncodingFromFile() to get the encoding.
    • syncSubtitles
      Start syncing a subtitle object with the VideoView
      param textObject: The subtitle to load
    Properties:
    • SubView As TextView [read only]
    • SubtitleDelay As Int
      Get how often in milliseconds to refresh the subtitles
  • Vitamio_VideoView
    Events:
    • Buffering (Percent As Int)
    • Complete
    • Error (MEDIA_ERROR As Int))
    • Info (What As Int, Extra As Int))
    • Prepared
    • SeekComplete
    Fields:
    • MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK As Int
    • MEDIA_ERROR_UNKNOWN As Int
    • VIDEO_LAYOUT_FIT_PARENT As Int
    • VIDEO_LAYOUT_ORIGIN As Int
    • VIDEO_LAYOUT_SCALE As Int
    • VIDEO_LAYOUT_STRETCH As Int
    • VIDEO_LAYOUT_ZOOM As Int
    • VIDEO_QUALITY_HIGH As Int
    • VIDEO_QUALITY_LOW As Int
    • VIDEO_QUALITY_MEDIUM As Int
    • ba As BA
    Methods:
    • BringToFront
    • CheckVitamioLibs As Boolean
      Returns whether the core Vitamio library files have been installed.
      If these files have not been installed, this method returns False and launches the Vitamio installer Activity.
      Your Activity's Finish method will be called and your Activity restarted once the files are installed.
      The installer will typically only run when your installed application is first run.
      //pBA:
    • GetBufferPercentage As Int
      Returns currently used buffer percentage.
    • GetCurrentPosition As Long
      Returns the current playback position in units of milliseconds.
    • GetDuration As Long
      Returns the video duration in milliseconds.
    • GetVideoAspectRatio As Float
      Returns the aspect ratio of the video. Result: the aspect ratio of the video, or 0 if there is no video, or the width and height if not available.
    • GetVideoHeight As Int
      Returns the height of the video.
    • GetVideoLayout As Int
      Returns current VideoLayout.
      Layout parameters: VIDEO_LAYOUT_ORIGIN or 0, VIDEO_LAYOUT_SCALE or 1, VIDEO_LAYOUT_STRETCH or 2, VIDEO_LAYOUT_ZOOM or 3, VIDEO_LAYOUT_FIT_PARENT or 4.
    • GetVideoWidth As Int
      Returns the width of the video.
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsBuffering As Boolean
      Checks whether the buffer is filled or not.
      Returns False if buffer is filled
    • IsInitialized As Boolean
    • IsPlaying As Boolean
      Tests whether the video is currently playing.
    • IsValid As Boolean
    • Pause
      Pauses the playback.
    • RemoveView
    • RequestFocus As Boolean
    • Resume
      Resumes the playback.
    • SeekTo (Milliseconds As Long)
      Seeks to specified time position.
      Parameters: Milliseconds - the offset in milliseconds from the start to seek to.
    • SendToBack
    • SetAVOptions (avOptions As Map)
      Sets Audio and Video (AV) options. Create a Map in B4A and pass on the Map within this method.
      You need to pass on AV options before starting the stream.
      The following Map key/values will always be included in the AV Options:
      ("rtsp_transport", "tcp")
      ("analyzeduration", "1000000")
      You will probably find other AV Options you can add by googling for FFMpeg and AV Options
      although if they will work or not is hard to say without trying them.
    • SetAdaptiveStream (Adaptive As Boolean)
      Adaptive streaming support, default is false
      set param adaptive to true if you want to enable adaptive stream
    • SetBackgroundImage (arg0 As Bitmap)
    • SetBufferSize (BufferSize As Int)
      Set the buffer size to fill before playback starts.
      Default is 1024KB.
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (Top As Int, Left As Int, Width As Int, Height As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetMediaController (MediaController1 As MediaController)
    • SetPlaybackSpeed (Speed As Float)
      Set video and audio playback speed
      Speed e.g. 0.8 or 2.0, default to 1.0, range in [0.5-2]
    • SetVideoChroma (Chroma As Int)
      Set the Video Chroma quality when playing video, default is VIDEOCHROMA_RGB565.
      Must be set before calling SetVideoPath/SetVideoUri.
    • SetVideoLayout (VIDEO_LAYOUT As Int, AspectRatio As Float)
      Set the display options.
      Default is VIDEO_LAYOUT_SCALE or 1.
      Layout parameters: VIDEO_LAYOUT_ORIGIN or 0, VIDEO_LAYOUT_SCALE or 1, VIDEO_LAYOUT_STRETCH or 2,
      VIDEO_LAYOUT_ZOOM or 3, VIDEO_LAYOUT_FIT_PARENT or 4.
      AspectRatio - video aspect ratio, will auto detect if 0.
    • SetVideoPath (VideoPath As String)
      Set the URI of the video to play.
      Pass either a URL or a file system path, an example: SetVideoPath(File.Combine(File.DirRootExternal, "test_video.mp4"))
    • SetVideoPathWithHeaders (VideoPath As String, Headers As Map)
      Sets the URL of the video together with headers associated
      with the http request for the stream you want to play
    • SetVideoQuality (VIDEO_QUALITY 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.
      Suggestion: use VIDEOQUALITY_HIGH or VIDEOQUALITY_MEDIUM (most modern android-devices can cope with higher settings).
      Default value is VIDEOQUALITY_LOW.
      Quality-Parameters: VIDEOQUALITY_HIGH or 16, VIDEOQUALITY_MEDIUM or 0, VIDEOQUALITY_LOW or -16
    • SetVideoUri (Uri1 As Uri)
      This method may be of limited use as the Uri object is not yet supported in B4A.
      The method is included though for future compatibility.
      You can use B4A's ContentResolver library if you want to pass on an URI object.
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • SetVolume (LeftVolume As Float, RightVolume As Float)
      Sets the volume.
      Unknown ranges to use (perhaps 1 to 15).
      Might be better to use Phone-library in B4A.
    • Start
      Starts or resumes playing.
    • StopPlayback
      Stops the playback.
    • Suspend
    Permissions:
    • android.permission.ACCESS_NETWORK_STATE
    • android.permission.INTERNET
    • android.permission.WAKE_LOCK
    Properties:
    • AudioAmplify As Float [write only]
      Amplify audio
      param ratio e.g. 3.5
    • Background As Drawable
    • Color As Int [write only]
    • CurrentFrame As Bitmap [read only]
      Returns current videoframe which can be used for screenshot.
    • Enabled As Boolean
    • HardwareDecoder As Boolean [write only]
      Set whether to use Hardware acceleration or not.
      Default is false.
    • Height As Int
    • Left As Int
    • Parent As Object [read only]
    • Position As Long
      Gets or sets the playing position (in milliseconds).
      Not an official Vitamio API method, used for compatibility with B4A's VideoView.
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int
Final notes:
I made available some years ago the very first wrapper of Vitamio here in the forum. Later @warwound wrapped subsequent versions of Vitamio.
I am now making Vitamio5 available here in the forum but this time as Donation ware. I have spoken with @warwound and he is fine with it.

I feel that a lot of efforts have been put into wrapping and testing Vitamio5 and that a small donation, to obtain it, is justified. The price is EUR 10,00 but of course you can donate more if you wish. You can donate using PayPal by clicking on my PayPal.Me link here:

https://PayPal.Me/moster67/EUR10

or you can use the Donation link in my signature.

After donating, please send me a PM (do not post here in this thread) and let me know your e-mail address that you used when donating with PayPal, the amount donated and the purpose (for instance Vitamio5). I prefer receiving a PM with this information so I can take note of your B4A licensed username. If you send this information by e-mail, please then include your B4A licensed username. Having your licensed B4A licensed username is important/required so I know if you are a donator or not if you ask for support here in this thread. I am sorry to say that if I receive a donation for less than EUR 10,00 and the purpose was for the Vitamio5 wrapper, I will not accept the donation. This may sound pompous but this is just to assure that the minimum price requested is received.

After receiving your donation and your PM, I will send you by e-mail (to the e-mail address you sent me in PM) a link from where you can download the wrapper along with a demo-app and instructions. The e-mail will have "Vitamio5 wrapper" as subject. If you do not receive an e-mail from me within a reasonable time (20-24 hours), please first check your spam-folder in your e-mail program. If you cannot find my e-mail, please then contact me by PM.

By donating, you are also motivating me to wrap future versions of Vitamio when they are made available. If and when they are released, I will wrap them to the best of my efforts and send all donators updated versions for free.
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User

moster67

Expert
Licensed User
Longtime User
If I recall correctly, the error dialog is present in the original compiled sources of VItamio5 (which I cannot modify) so I don't think it is possible to remove it or change its behavior.
However, just to be sure, I will check later to see if there is a way to do something about it.
 

bigsuntat

New Member
Hi monster67 , i will to payment but i ask you it's work for m3u8 (can play , volume down, volume up, check who doing stream counter (see together link), check link stream error right ?)
 

moster67

Expert
Licensed User
Longtime User
When using the library you can reduce or increase the volume.
I have no experience with m3u8 so if you send a link, then I can test. I don't understand your other questions/requirements. Please explain better.
 

bigsuntat

New Member
When using the library you can reduce or increase the volume.
I have no experience with m3u8 so if you send a link, then I can test. I don't understand your other questions/requirements. Please explain better.


please make sure it can show full screen on device thank you
 
Last edited:

moster67

Expert
Licensed User
Longtime User

moster67

Expert
Licensed User
Longtime User
I have no problems to test links, various encoding formats, containers and so forth.
But please do not post them here in the forum, especially if they are links of dubious origin such as iptv.
If you want to test some links, send them to me as a PM. Also make sure they are working using VLC on a computer before sending them to me.
 
Last edited:
@@moster67
Does it have an option to feed media from stream.

like this one
 

aidymp

Well-Known Member
Licensed User
Longtime User
Donated again yesterday as i have lost the lib, I understand people dont live on the internet, so this is just a gentle reminder. Thanks!
 

moster67

Expert
Licensed User
Longtime User
Donated again yesterday as i have lost the lib, I understand people dont live on the internet, so this is just a gentle reminder. Thanks!
Yep, I am not always online :)
Thanks. See your email. I will reimburse your 2nd donation since you already donated a long, long time ago.
 

astronald

Active Member
Licensed User
Longtime User
Hello i make my donation, thanks for share your works?
I have a video on server with Basic Auth, Can i directly play the video?

Thanks Ronald.
 

moster67

Expert
Licensed User
Longtime User
Thank you for your donation.
I have sent you a PM and separate email.
 
Top