B4A Library VitamioBundle

Discussion in 'Additional libraries, classes and official updates' started by warwound, Nov 29, 2013.

  1. warwound

    warwound Expert Licensed User

    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.

    Code:
    #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, 00100%x100%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.basic4ppc.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: Feb 3, 2014
  2. yo3ggx

    yo3ggx Active Member Licensed User

    Hi Martin,

    It works perfect and is a nice bundle in a single file, but I'm still trying to find a way to recompile the library (libffmpeg.so) in order to be accepted by the application. Seems to be a dead end for me...:(

    With any other version of libffmpeg.so I get the error:
    Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 19280 (tamiobundledemo)

    I've tried with both ndk 8b and 9b, with the same result.

    The procedure is straight forward described here:
    http://www.vitamio.org/en/2013/Tutorial_0509/13.html
    and generates a libffmpeg.so file for each processor.

    Archiving the new file into the libarm.so package does not produce the expected results...

    There is anybody else succeeding to recompile a valid version of libffmpeg?
    Or to have one with libopus support....

    Thank you,
    Dan
     
  3. warwound

    warwound Expert Licensed User

    Ah ha!

    That page refers to Vitamio version 3 - that could explain the problem.

    I'm now uploading VitamioLibrary version 3 to the same link as in my first post - can you try using your libffmpeg.so with version 3 and report what happens?
    (You might have to wait a few minutes until the upload completes, VitamioBundle-3.zip is 5,054,315 Bytes in size).

    Martin.
     
  4. yo3ggx

    yo3ggx Active Member Licensed User

    Hi Martin,

    I was not able to find the link to VitamioBundle-3.zip in that post.
    Can you put it here?

    Thanks,
    Dan
     
  5. warwound

    warwound Expert Licensed User

  6. yo3ggx

    yo3ggx Active Member Licensed User

    Yes, this is ok.
    I will do some tests this evening and be back with the result.

    Thank you,
    Dan
     
  7. yo3ggx

    yo3ggx Active Member Licensed User

    Hi Martin,

    With the version 3 it works. I have a big latency (the audio start playing after more than 20s), but it works with the recompiled ffmpeg library.
    Unfortunately the library version used in script does not support adding libopus without patching. I will try later today with the latest git version to see if it still works.

    I wonder what's the difference in the way libffmpeg.so is used between version 3 and 4...

    I intend to use the library exclusively to play opus/ogg audio, so I will want to strip the video part from the library.

    Thanks,
    Dan
     
  8. evansus

    evansus Member Licensed User

    Hi All
    First off thanks to Warwound for updating the library to the newest version. There are some features that I am interested in using - namely the ability to vary playback rate. I am new to B4A programming so thought I would try this example first.
    I downloaded the files and followed the instructions.
    I got the code loaded and it looks like it is compiling but then I get the message shown below in the log window. I am sure it is something to do with the manifest file not being correct and I remember seeing a caution to update this file.
    Can someone tell me what code needs to be entered in the manifest?
    In the manifest editor I have added:
    AddApplicationText(<activity android:name="io.vov.vitamio.activity.InitActivity" android:windowSoftInputMode="stateAlwaysHidden"
    android:theme="@android:style/Theme.NoTitleBar"
    android:launchMode="singleTop"
    android:configChanges="orientation|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"/>)

    Also, in looking at
    VitamioVideoView1 and
    VitamioMediaController1 I do not see where the rate of playback can be altered.




    Thanks for any help
    David
    Log output on compile
    Code:
    ** Activity (main) Create, isFirst = true **
     
     
    ** 
    Activity (main) Resume **
     
     
    ** 
    Activity (main) Pause, UserClosed = true **
     
     
    java.lang.RuntimeException: Unable 
    to start activity ComponentInfo{b4a.example/io.vov.vitamio.activity.InitActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x0
     
     
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
        at android.app.ActivityThread.access$600(ActivityThread.java:141)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:5041)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
        at dalvik.system.NativeStart.main(Native Method)
    Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0
        at android.content.res.Resources.getText(Resources.java:230)
        at android.content.res.Resources.getString(Resources.java:314)
        at android.content.Context.getString(Context.java:327)
        at io.vov.vitamio.activity.InitActivity$1.onPreExecute(InitActivity.java:49)
        at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586)
        at android.os.AsyncTask.execute(AsyncTask.java:534)
        at io.vov.vitamio.activity.InitActivity.onCreate(InitActivity.java:65)
        at android.app.Activity.performCreate(Activity.java:5104)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
        ... 11 more
     
  9. warwound

    warwound Expert Licensed User

    Your project is missing one or more of the required resources.
    Look at my demo app, it can be found here: http://b4a.martinpearman.co.uk/vitamiobundle/
    Look in the Objects/res folder - there you'll see a bunch of resource files that must be copied to any project that uses the library.

    I can't see from the posted exception which resource(s) you are missing but that is the cause of the exception.

    Vitamio promotes itself with many features but documents hardly any - from variable speed playback to caching network video and lots more.
    It's tricky working out how to use a library when it's poorly documented and has no online support :(.
    I'll take a look later and see if i can see where variable speed playback is set then post again.

    Martin.
     
  10. evansus

    evansus Member Licensed User

    Many Thanks Martin
    I will follow the instructions you provided in an earlier post much more carefully and hopefully get this working.
    Regards
    David
     
  11. evansus

    evansus Member Licensed User

    Hi Martin
    as a follow up. I copied the res folder contents and that got rid of the error - Thanks.
    However, I am using the AVD (not an actual device) and I have an issue and a question

    1. I used libarm_full and changed this to libarm.so in my folder - can this be used to access Http addresses from a virtual device? Do I need to add another library to allow use of URLs? I plan on accessing URLs and files.
    2. I added a log entry that tells when CheckVitamioLibs returns true.
    I get the program to compile and it starts the installation on the virtual device. I see "Installing decoders" on the AVD screen and then after a few seconds the Fatal signal error message shown below crops up.
    ** Activity (main) Create, isFirst = true **
    VitamioVideoView1.CheckVitamioLibs =false
    ** Activity (main) Resume **
    ** Activity (main) Pause, UserClosed = true **
    Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 8975 (AsyncTask #1)

    Any ideas on this - is it just something in the AVD?

    3. This is a general question but if I am using the AVD can I point to a file that is on my PC?
    a) how do I convert the path to URI (do I need to?).
    b) I have a file for example at C:\Gen1.mp4. What should I do to emulate this file on the device?
    Feel free to point me to other tutorials if I need a better grounding.

    David
     
  12. abay1968

    abay1968 Member Licensed User

    Using your wrapper my app cannot play mms/rtsp streaming but using wrapper provided by moster67 it can. Any suggestion?
     
  13. warwound

    warwound Expert Licensed User

    Did you read the readme.txt file that's included with the library download?
    There's a choice of 2 different .so library files that can be used in your project: libarm_online.so or libarm_full.so.
    I'd expect the libarm_online.so file to be capable of decoding mms/rtsp streams BUT it may be that you require the libarm_full.so?

    Which of these 2 files have you included in your project?

    Martin.
     
  14. abay1968

    abay1968 Member Licensed User

    I have followed the instructions given and also tried both libraries. So far i have tested rtmp, mp3, mp4, flv, wmv streams and it's worked. Only mms/rtsp failed.
     
  15. warwound

    warwound Expert Licensed User

    I'm not sure what to suggest - i'm not a user of this library.
    One option could be to try version 3 which is available here: http://b4a.martinpearman.co.uk/vitamiobundle/ (look for VitamioBundle-3.zip).
    Version 3 is 'self contained' and requires no additional codec/plugin download unlike moster67's version.

    Martin.
     
  16. abay1968

    abay1968 Member Licensed User

    Problem solved by removing the existings app that uses libarm_online.so and then reinstall the new one that uses libarm_full.so (cannot just update/replaced).

    Thanks.

    ** Sorry for my broken english.
     
  17. evansus

    evansus Member Licensed User

    Hi All
    After some time to play with the Vitamio411 library I have the following notes that I hope will help others.
    All of these are probably elsewhere in the forum or follow Martin's readme CAREFULLY but I am new to B4A and so this was not the only learning curve!.
    3 things that tripped me up were
    1. not adding the following text to the manifest file (copy and paste)
    AddApplicationText(<activity android:name="io.vov.vitamio.activity.InitActivity" android:windowSoftInputMode="stateAlwaysHidden"
    android:theme="@android:style/Theme.NoTitleBar"
    android:launchMode="singleTop"
    android:configChanges="orientation|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"/>)
    2. I was having problems testing using any of the files referenced in the other posts (even though I could open them in various browsers etc)
    I copied mp4 files to the sdCard to test using these and I set up a first Activity that would allow me to open these files.
    I was still using debug mode and had the USB cable attached and every time I used file dialog I could not see the files (searching for mp4 files) but could see JPG files (if I did NOT set a file filter). I finally remembered some post that said Windows uses the SDcard like an external drive and thought this may be blocking access somehow.
    3. I kept trying to run from debug and kept getting errors (see earlier posts) and, combined with the inability to access the files, I changed to use Release mode compile

    Upon compiling I removed the USB cable, could "see" my mp4 files and could activate them and run them.
    FYI this is running on Samsung Galaxy tab 3 (7") and looks great!


    Martin - thanks for building the library - it is a great asset. Any luck in finding where the play rate can be modified? I really would like to be able to change rates as indicated in the latest Vitamio update. Having this capability would be fantastic.

    Many thanks

    Evansus
     
  18. warwound

    warwound Expert Licensed User

    Can you test the attached update?
    The attachment conatins just the library .jar and .xml files - the folders 'dist' and 'res' are not included.
    Just overwrite your existing library .jar and .xml file with the attached versions.

    The Vitamio_VideoView has a new method:

    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]


    Entirely untested - hope you can do the tests for me.

    Martin.

    [EDIT]
    See http://www.basic4ppc.com/android/forum/threads/vitamiobundle.35121/page-2#post-214468 for the updated files.
    [/EDIT]
     
    Last edited: Jan 8, 2014
    moster67 likes this.
  19. warwound

    warwound Expert Licensed User

    @evansus I'm not sure if that link in my last post will work.
    Network problem here and the upload to my webspace seems to have only partly completed - the zip file will not open.

    Once the network here is back up and working i'll upload the file again.

    Martin.

    [EDIT]The zip file is now correctly uploaded[/EDIT]
     
    Last edited: Jan 7, 2014
  20. evansus

    evansus Member Licensed User

    Hi Martin
    That worked like a charm.
    I now have a slider that can vary the rate and it updates the video VERY smoothly.
    Thanks so much for making this available.

    Cheers
    Evansus
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice