B4A Library VitamioBundle

This library wraps the latest version of the VitamioBundle - that's currently version 4.2.0.
You can find more info on the VitamioBundle here:
https://github.com/yixia/VitamioBundle.

I'm not a user of this library, i just developed it for various other forum members.
So i'll post a basic code example and leave anyone that's interested to experiment for themselves to see what the library is capable of.

B4X:
#Region  Project Attributes 
   #ApplicationLabel: VitamioBundle4 example
   #VersionCode: 1
   #VersionName: 
   'SupportedOrientations possible values: unspecified, landscape or portrait.
   #SupportedOrientations: unspecified
   #CanInstallToExternalStorage: False
   #AdditionalRes: C:\Users\foobar\Basic4Android\VitamioBundle-4-2-0\library_files\res, io.vov.vitamio
#End Region
#Region  Activity Attributes 
   #FullScreen: True
   #IncludeTitle: True
#End Region
'Activity module
Sub Process_Globals
End Sub
Sub Globals
   Dim VitamioMediaController1 As Vitamio_MediaController
   Dim VitamioVideoView1 As Vitamio_VideoView
End Sub
Sub Activity_Create(FirstTime As Boolean)
   '   take a look at the manifest editor to see the additional entry activity required in order to use VitamioBundle
  
   '   VitamioBundle version 4.2.0 uses the new #AdditionalRes project attribute
   
   '   check if the VitamioBundle core is installed
   '   if this is the first time that the installed application has been started then the core will NOT be installed
   '   otherwise the core should be already installed
  
   '   if the core is NOT installed then CheckVitamioLibs returns False and this Activity's Finish method is called by the library
   '   the core is then installed and this Activity will be restarted
   '   CheckVitamioLibs will now return True and you can proceed to use the library
  
   If VitamioVideoView1.CheckVitamioLibs Then
  
     VitamioVideoView1.Initialize("VitamioVideoView1")
     Activity.AddView(VitamioVideoView1, 0, 0, 100%x, 100%y)
    
     VitamioMediaController1.Initialize("VitamioMediaController1")
    
     VitamioVideoView1.SetMediaController(VitamioMediaController1)
     VitamioVideoView1.SetVideoQuality(VitamioVideoView1.VIDEO_QUALITY_HIGH)
    
     VitamioVideoView1.SetVideoPath("http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8")
     '   VitamioVideoView1.SetVideoPath(File.Combine(File.DirRootExternal, "test_video.mp4"))
    
   End If
  
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
'   events raised by Vitamio_MediaController
Sub VitamioMediaController1_Hidden
   Log("VitamioMediaController1_Hidden")
End Sub
Sub VitamioMediaController1_Shown
   Log("VitamioMediaController1_Shown")
End Sub
'   events raised by Vitamio_VideoView
Sub VitamioVideoView1_BitmapSubtitleUpdated(Bitmap1() As Byte, Width As Int, Height As Int)
  
End Sub
Sub VitamioVideoView1_Buffering(Percent As Int)
   '   Log("VitamioVideoView1_Buffering: "&Percent)   '   commented out to avoid excess logging
End Sub
Sub VitamioVideoView1_Complete
   Log("VitamioVideoView1_Complete")
End Sub
Sub VitamioVideoView1_Error(MEDIA_ERROR As Int) As Boolean
   '   this event Sub must return a Boolean value to indicate whether it has handled the error or not
   '   returning True will prevent the library from taking any action such as displaying an error message
   Log("VitamioVideoView1_Error")
  
   Return True
End Sub
Sub VitamioVideoView1_Info(What As Int, Extra As Int) As Boolean
   '   what does this event mean?
   '   what do the Int parameters represent?
  
   '   Log("VitamioVideoView1_Info")   '   commented out to avoid excess logging
   Return False    '   indicates that this Sub has NOT handled the event and that the library should handle it
End Sub
Sub VitamioVideoView1_Prepared
   Log("VitamioVideoView1_Prepared")
End Sub
Sub VitamioVideoView1_SeekComplete
  
End Sub
Sub VitamioVideoView1_TextSubtitleUpdated(SubText As String)
  
End Sub

Previous versions of the VitamioBundle have already been posted (by myself) on this thread:
http://www.b4x.com/android/forum/threads/video-view-fullscreen-and-on-top-on-ouya.31034/
The old links in that thread will no longer work - i've recently changed webhosts.

But the thread is full of useful info for anyone that's trying to use the VitamioBundle.
You'll read that the VitamioBundle is far from perfect and that it has a rather obscure licensing model that you as the developer will have to handle.

The library is a 8.7MB download - far too big to attach to this post.
So the library is currently available from my webspace at:
http://b4a.martinpearman.co.uk/vitamiobundle/
You'll also find the b4a demo project at the same link.
(VitamioBundle-4-2-0-library-files.zip and VitamioBundle-4-2-0-demo.zip are the latest versions).

Martin.
 
Last edited:

holdemadvantage

Active Member
Licensed User
Longtime User
Hi , thanks for this library, very interesting.
I try new lib 4.2.0 modified and with the attached example you can find here

Example works for online flv (both device samsung note III and sansung tablet GT-P5220) , for m3u8 online it works on note 3 but not on tablet (do you imagine why?)

The thing that have stopped me was the big lags during streaming

i try to VitamioVideoView1.SetVideoQuality(VitamioVideoView1.VIDEO_QUALITY_LOW)
and to
VitamioVideoView1.SetBufferSize(10000) 'increase buffering size before starts

but with no luck, still lags a lot
Any suggestions?

Tnx in advance
 

wahyuway

Member
Licensed User
Longtime User
Hi Martin,
There is no Vitamio MediaPlayer?
I cant play this stream rtmp://cdn-edge.sim-indonesia.com:443/radio

Oh, and could you update vitamio plugin to the latest version?
Tks
 

Johnmcenroy

Active Member
Licensed User
Longtime User
Hi Martin
Thank you very much for library.
It's a pity , but I have some problems. Video doesn't seem to resize to its view.It doesn't scale.
As you wrote here :
http://www.b4x.com/android/forum/th...n-and-on-top-on-ouya.31034/page-3#post-184486

There are some variants but I can't understand how to implement this in B4A through XML Layout Builder library:
http://stackoverflow.com/questions/17202603/vitamio-full-screen-videoview
http://stackoverflow.com/questions/16581273/vitamio-video-center-issue
https://github.com/yixia/VitamioBundle/tree/master/vitamio-sample/res/layout
https://bbs.vitamio.org/topics/43?locale=en

Update:
Solved this problem in this way
1. I have created an XML layout for Vitamio videoview:
B4X:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
  
    <io.vov.vitamio.widget.VideoView
        android:id="@+id/surface_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
      
</RelativeLayout>
2. Then I have loaded this layout to panel:
B4X:
pnlLayout.Initialize("")

    Activity.AddView(pnlLayout,150dip,0,100%x-150dip,100%y)
    xmlLayout.LoadXmlLayout(pnlLayout,"vitamio_layout")

    VitamioVideoView1.Initialize("VitamioVideoView1")
    VitamioVideoView1 = xmlLayout.GetView ("surface_view")

So video occupy only the size of panel , but you must preserve aspect ratio of video by checking its width and height.

Thanks
John
 
Last edited:

Swissmade

Well-Known Member
Licensed User
Longtime User
Hi All,
Can this Library also be used with B4J???
 

Swissmade

Well-Known Member
Licensed User
Longtime User
I don't know - i'll have to leave you to research the b4j options...

Martin.
Search for this already for a long time :(and found nothing what can be used with B4J.
Anyway thanks Martin.;)
 

moster67

Expert
Licensed User
Longtime User
Have you checked out VLC (Video on Lan)? Maybe it is possible to use VLC within B4J?

Many years ago I wrote a program in VB.Net where I used VLC as an object and embedded it within the program. I guess this would be possible with a Java-program as well although the procedure how to do it with B4J I don't know. Just an idea.

Edit: check the links at the bottom of this page:
https://wiki.videolan.org/LibVLC/
 

Swissmade

Well-Known Member
Licensed User
Longtime User
Have you checked out VLC (Video on Lan)? Maybe it is possible to use VLC within B4J?

Many years ago I wrote a program in VB.Net where I used VLC as an object and embedded it within the program. I guess this would be possible with a Java-program as well although the procedure how to do it with B4J I don't know. Just an idea.

Edit: check the links at the bottom of this page:
https://wiki.videolan.org/LibVLC/

Yes I have Check this but this is not working nice and smoothly.
If I Really have the time to spend some weeks I will find or write this by my one.
At the moment if possible I need the easy way find a library can be used for B4J.
My need is to stream IP-Camera's with MJpeg and H264.
 

moster67

Expert
Licensed User
Longtime User
My need is to stream IP-Camera's with MJpeg and H264.

Vitamio cannot stream nor transcode. Vitamio is only for displaying an incoming stream (not for broadcasting/transmitting it). If you want to stream your source (IP-camera), then I guess I believe you need a library using for instance FFMPEG which will permit you to broadcast (or transcode) a stream. VLC is one of the solutions which comes into mind. There are other FFMPEG-products as well (google for it) however if they support Java I don't know.
 

Swissmade

Well-Known Member
Licensed User
Longtime User
Vitamio cannot stream nor transcode. Vitamio is only for displaying an incoming stream (not for broadcasting/transmitting it). If you want to stream your source (IP-camera), then I guess I believe you need a library using for instance FFMPEG which will permit you to broadcast (or transcode) a stream. VLC is one of the solutions which comes into mind. There are other FFMPEG-products as well (google for it) however if they support Java I don't know.
I know FFMPEG good library and I use this in Visual Studio to convert streams to Images.
But for B4J we have a problem. Some while ago I have play with VLC and the Library for B4J but the result was disappointed.
 

moster67

Expert
Licensed User
Longtime User
I know FFMPEG good library and I use this in Visual Studio to convert streams to Images.
But for B4J we have a problem. Some while ago I have play with VLC and the Library for B4J but the result was disappointed.

Well, then I really don't know. In either case, I don't think Vitamio is what you are looking for as I explained in my previous post so I think it is better you open a new thread for your query in order to keep this thread focused on Vitamio.

If something comes into my mind, I will let you know.
 

Swissmade

Well-Known Member
Licensed User
Longtime User
Well, then I really don't know. In either case, I don't think Vitamio is what you are looking for as I explained in my previous post so I think it is better you open a new thread for your query in order to keep this thread focused on Vitamio.

If something comes into my mind, I will let you know.

Thanks
 

merlin2049er

Well-Known Member
Licensed User
Longtime User
Hmm, can you add the vitamio videoview in the designer , instead of using activity.addview(etc...) in code.
 

merlin2049er

Well-Known Member
Licensed User
Longtime User
Hi Martin
Thank you very much for library.
It's a pity , but I have some problems. Video doesn't seem to resize to its view.It doesn't scale.
As you wrote here :
http://www.b4x.com/android/forum/th...n-and-on-top-on-ouya.31034/page-3#post-184486

There are some variants but I can't understand how to implement this in B4A through XML Layout Builder library:
http://stackoverflow.com/questions/17202603/vitamio-full-screen-videoview
http://stackoverflow.com/questions/16581273/vitamio-video-center-issue
https://github.com/yixia/VitamioBundle/tree/master/vitamio-sample/res/layout
https://bbs.vitamio.org/topics/43?locale=en

Update:
Solved this problem in this way
1. I have created an XML layout for Vitamio videoview:
B4X:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <io.vov.vitamio.widget.VideoView
        android:id="@+id/surface_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
    
</RelativeLayout>
2. Then I have loaded this layout to panel:
B4X:
pnlLayout.Initialize("")

    Activity.AddView(pnlLayout,150dip,0,100%x-150dip,100%y)
    xmlLayout.LoadXmlLayout(pnlLayout,"vitamio_layout")

    VitamioVideoView1.Initialize("VitamioVideoView1")
    VitamioVideoView1 = xmlLayout.GetView ("surface_view")

So video occupy only the size of panel , but you must preserve aspect ratio of video by checking its width and height.

Thanks
John


Hmm, great.

I wanted my videoview to be @ 90%x & 90%y;

I had in my code...
B4X:
VitamioVideoView1.Initialize("VitamioVideoView1")
Activity.AddView(VitamioVideoView1, 0%x, 0%y,  90%x, 90%y)

But it just ignores it, and takes up the full screen. Where do you put the xml file?
 

Johnmcenroy

Active Member
Licensed User
Longtime User
Hmm, great.

I wanted my videoview to be @ 90%x & 90%y;

I had in my code...
B4X:
VitamioVideoView1.Initialize("VitamioVideoView1")
Activity.AddView(VitamioVideoView1, 0%x, 0%y,  90%x, 90%y)

But it just ignores it, and takes up the full screen. Where do you put the xml file?

Hi Merlin
See XML Layout Builder library for this

Regards
John
 
Top