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:

moster67

Expert
Licensed User
Longtime User
I had a look and VIDEO_LAYOUT_FIT_PARENT seems to work correctly. To center it, that is something you need to yourself.
You could call the following sub after you have invoked SetVideoLayout()

B4X:
Sub CenterVideoView
  
    If GetDeviceLayoutValues.Width < GetDeviceLayoutValues.Height Then 'portrait
            vvvit5.Top = (100%y - vvvit5.Height) / 2
    Else if GetDeviceLayoutValues.Width > GetDeviceLayoutValues.Height Then 'landscape
          vvvit5.Left = (100%x - vvvit5.Width) / 2
        vvvit5.Top = (100%y - vvvit5.Height) / 2
    End If

End Sub

If you are using the sample-app and you are implementing a method somewhere in your code which iterates different videolayouts, then remember to remove the existing SetVideoLayout-method which is present in the sample-app in the Prepare-event.
 

aidymp

Well-Known Member
Licensed User
Longtime User
Hi,firstly this lib is excellent!

I have noticed a problem with vitamino though, not only this one but the old version 4, I was hopiing that 5 would be better but its not.

This is not anything you have done, and I dont expect a fix just because I donated, but as soon as I add anything "firebase" the app fails to run!

it opens and closes with no errors!? i presume something is in conflict do you have any idea what it could be?

here is what i did,

your initial demo, I just added the base filebase code to the manifest, and the libraries. no code

my app opens and closes immediately. Again, this also happens with vitamino 4!

The lib is still excellent, thank you for wrapping it. but any tips as to getting firebase working with it would be great!

Thanks

Aidy
 
Last edited:

moster67

Expert
Licensed User
Longtime User
I have never used firebase so I can't really tell.
You can send me by pm the sample project with your extra code and I will check this evening so I can try to better understand the problem and see if it can be resolved.
 

aidymp

Well-Known Member
Licensed User
Longtime User
Just to let you know, i have re added the manifest for, firebase admob, notifications, and don manfreds, remoteconfig, and it works fine, I am not sure what the problem was, but it seems fine now sorry.

The library is working as expected, very happy!

Thanks

Aidy
 

moster67

Expert
Licensed User
Longtime User
can it play rtmp ,rtsp, m3u8?
please test or confirm, I will donate as soon
rtmp://203.145.115.34/Eazy/Eazy-Listen-Low
rtmp://lb-media.mcot.net:1935/MCOTRadio/fm99.stream
rtmp://27.131.144.177/103likefm/live

http://symc-cdn02.bkk01.violin.co.th:1935/liveedge/292277227873_300/playlist.m3u8

thanks

I checked with Vitamio but I also I compared with VLC for windows (which is famous for being able to play nearly all streams and formats available)

"rtmp://203.145.115.34/Eazy/Eazy-Listen-Low"
Vitamio: works but takes a while until streaming starts
VLC: works but slow starting the stream. Same as Vitamio

"rtmp://lb-media.mcot.net:1935/MCOTRadio/fm99.stream"
Both Vitamio and VLC cannot connect. Seems the streaming link is offline

"rtmp://27.131.144.177/103likefm/live"
Both Vitamio and VLC cannot stream.

"http://symc-cdn02.bkk01.violin.co.th:1935/liveedge/292277227873_300/playlist.m3u8"
Both Vitamio and VLC reports authorization/access denied problems

As you can see, Vitamio and VLC behave the same.
 

victormedranop

Well-Known Member
Licensed User
Longtime User
I just received this AMAZING lib, the must importan thing if video quality control.
but one thing why always display in format 4:3 an I know my streaming are 16:9.

regards,

Victor
 

moster67

Expert
Licensed User
Longtime User
why always display in format 4:3 an I know my streaming are 16:9
The wrapper simply wraps the original methods in Vitamio5 which handle VideoLayout and AspectRatio.
When using this method:
B4X:
vvvit5.SetVideoLayout(vvvit5.VIDEO_LAYOUT_XXX,0)
and you set 0 as the 2nd parameter, then Vitamio5 should adjust aspect ratio automatically.
 

moster67

Expert
Licensed User
Longtime User
@Almora
I have sent you e-mail with payment instructions.
PS: it's better you use PM here in the forum (conversation)
 

Almora

Well-Known Member
Licensed User
Longtime User
hi..

I added the panel. I got the video into the panel. But it goes out of the video panel landscape.

B4X:
panel1.addview(vvvit5, 0, 0, panel1.width, panel1.height)

I've tried. Did not work.
 

moster67

Expert
Licensed User
Longtime User
I've tried. Did not work.
I sent you by email your test-project with the necessary corrections.
In your case you must use "VIDEO_LAYOUT_FIT_PARENT" and update Vitamio's layout with those of the panel.
I guess your case was exactly the reason why Vitamio added "VIDEO_LAYOUT_FIT_PARENT" in the 5th version...
 

jazzzzzzz

Active Member
Licensed User
Longtime User
Does RTSP live streams works good in this library? I have tried rtsp on vitamio 4.2 bundle but the app crashes without any log..Can some one confirm RTSP is working or not?

Does multiple video playback works in vitamio5??
 
Last edited:

moster67

Expert
Licensed User
Longtime User
@jazzzzzzz
Please provide me with a working rtsp stream and I can check (if it is not a public link, then send it by PM).
Does multiple video playback works in vitamio5
Never tried. If it works with earlier versions (found here on the forum) then it should work with Vitamio5 or send me a test project in Vitamio4.2 and I can try.
 

jazzzzzzz

Active Member
Licensed User
Longtime User
@jazzzzzzz
Please provide me with a working rtsp stream and I can check (if it is not a public link, then send it by PM).

Never tried. If it works with earlier versions (found here on the forum) then it should work with Vitamio5 or send me a test project in Vitamio4.2 and I can try.

I have attached Vitamio 4.2 bundle based app which contains both rtsp and rtmp sample links.In 4.2 if rtsp is used app is crashing and rtmp is working fine..Please test the same in the latest version you have.

Also please create 2 videoview in same screen and give these two links and see whether both are playing well in your device.(I assume your device is good enough)
 

Attachments

  • vitamio4.zip
    34 KB · Views: 368

moster67

Expert
Licensed User
Longtime User
Well, I tested on an emulator and both links (rtsp and rtmp) play/work fine.
If it can play two videos at the same, I don't know. According to the (old) docs here, it cannot:
Cann't play two videos at the same time.
Does it work with Vitamio4.2?
I can test with Vitamio5 but only if I find some time this evening.
 
Top