B4A Library B4ATextureVideoView wrapper -another VideoView

Here is another VideoView library....

This is a VideoView based on a TextureView instead of a SurfaceView (the standard VideoView in the Audio-library uses a SurfaceView).

B4ATextureVideoView offers the same capabilities as the standard VideoView but, unlike the standard VideoView, B4ATextureVideoView behaves as a regular view. This key difference allows it to be moved, transformed, animated, etc. You can even take screenshots. It is also better suited to be used in scrollable containers such as Scrollviews/listviews.

From an Android-blog:
Because a SurfaceView’s content does not live in the application’s window, it cannot be transformed (moved, scaled, rotated) efficiently. This makes it difficult to use a SurfaceView inside a ListView or a ScrollView. SurfaceView also cannot interact properly with some features of the UI toolkit such as fading edges or View.setAlpha(). SurfaceView has unpredictable behavior inside scrollable container, unpredictable behavior with animations, there is no way to crop content.

To solve these problems, Android 4.0 introduces a new widget called TextureView that relies on the hardware accelerated 2D rendering pipeline and SurfaceTexture. TextureView offers the same capabilities as SurfaceView but, unlike SurfaceView, behaves as a regular view. This key difference allows a texture view to be moved, transformed, animated, etc. You can even take screenshots.

You will find the same features as in the standard B4A-wrapper of VideoView although I have added a few more:
- a method for taking a screenshot
- some events missing in the B4A-wrapper of the standard VideoView (Error, Prepared, Info)
- you can get VideoWidth and VideoHeight of the running video

The video codecs supported are the same as the standard VideoView.

This means it should be very quick to port your current app to use B4ATextureVideoView instead of the standard one.

Note: minimum API level is 14

Version 0.30:
-added VideoWidth and VideoHeight
Version 0.50:
-should now be compatible with the the Sender Object


I attach a sample-project and library.
 

Attachments

  • B4ATextureVideoViewSample.zip
    7.4 KB · Views: 738
  • 1.png
    1.png
    92.3 KB · Views: 652
  • 2.png
    2.png
    217.2 KB · Views: 649
  • libs_v0_50.zip
    18.4 KB · Views: 712
Last edited:

moster67

Expert
Licensed User
Longtime User
I get a bad screenshot from your example (not proportionate - stretched):
It is just a bitmap shown in an imageview. Maybe if you set gravity to "center" instead of "fill" in the imageview, it might be shown better. I didn't put much effort into the sample app - I just wrote it to show how to use the features.

However, it might be useful to get hold of the playing video's Width and Height. I will see if that is possible.
 

moster67

Expert
Licensed User
Longtime User
Version 0.30:
-added VideoWidth and VideoHeight

Modified the sample-project.

Note: Since one now also can get VideoWidth and VideoHeight of the running video and also the height and width of the TextureVideoView, I believe one should be able to take and save a screenshot in the right dimensions. In my sample, I did not explore the possibilities so I leave that up to you users of this library. If you find a good way of doing it, please share the code.
 

itgirl

Active Member
Licensed User
Longtime User
Indeed this is a big solution i had alot of problems using the videoview in scrollview and it just give me a headache, thank you so much for this great LIB
 

itgirl

Active Member
Licensed User
Longtime User
Hello i think there's something wrong as you can see if i use Sender i get error

B4X:
Sub MovPlayer_Complete
    Dim vv As B4ATextureVideoView = Sender
    vv.Play
End Sub

return error

B4X:
java.lang.ClassCastException: com.tillekesoft.texturevideoviewwrapper.TextureVideoViewWrapper cannot be cast to com.sprylab.android.widget.TextureVideoView
 

moster67

Expert
Licensed User
Longtime User
I will check as soon as I have a moment.
In the meantime can you post a demo project showing the problem? Thanks.
 

itgirl

Active Member
Licensed User
Longtime User
its when i added the
_Complete
event it happens , also if the video is global variable it's easy we can just use the variable.play but sometimes we need the sender so it's pretty important

the project is attached ;) HERE
 

moster67

Expert
Licensed User
Longtime User
Just updated the first post with:

Version 0.50:
-should now be compatible with the Sender Object
 
Last edited:

JS Hart

Member
Licensed User
Longtime User
Hello, and thanks for all the contributions for Video extensions.

I've been investigating the possibility of making a video replay app for the sport of fencing. I'll need to be able to capture the video (which seems easy enough) while also capturing a (UDP) network datastream sent from the fencing scoring device (which I make, so that's already understood.) I want to replay the captured video, automatically cued to a few seconds before a hit arrived and play the video in slow motion to a few seconds after the hit arrived. I also want to add markers to the replay indicating the frame when the hit arrived.

So, I've been looking at this TextureVideoView wrapper as well as the VLC library. I can see that adding additional panels and labels to the replay should be possible since your example has the snapshot button view added, but I don't see any way to play in non-real-time so far. Using the VLC library, I tried manually advancing the video position frame-by-frame while paused to simulate 50% speed, but so far I have not gotten that to work either. Any suggestions?

Also, the TextureVideoView example you provided won't install on my Galaxy S5 (Marshmallow.) It just says "X App not installed." But on my Motorola Moto 5 with Android 5.1, it works fine. Any idea what causes this?

Thanks.

J. S. Hart
 

moster67

Expert
Licensed User
Longtime User
Nice idea!

1) the B4ATextureVideoView wrapper is essentially the standard VideoView provided by B4A except the fact that is uses a TextureView instead of a SurfaceView. In addition, I threw in some extra events and the possibility to save a screenshot. Unfortunately you cannot show a video in slowmotion since there is no such method available in Android.

2) what regards vlcb4a, it does have a method which permits showing a video in slowmotion although in my wrapper I have not exposed it. I am currently rewriting vlcb4a and I will include it with next update. Unfortunately, I cannot provide a method to take a screenshot since it is not implemented in the original sources.

The solution would be to use my Vitamio5 wrapper which has methods both for slowmotion and taking screenshots.

Why the B4ATextureVideoView example app won't install on your Galaxy S5 with Marshmallow I don't know. I don't have a physical device running API 23 but using the emulator, the example app installs correctly and works just fine. I can't really help you there but try to google for "App not installed" and see if you can find some useful information. You could also try to install the example app using ADB (again you need to google for instructions - it was ages ago I did it last time) and see if it generates any logs that might help you tracking down the problem.
 
Last edited:

susu

Well-Known Member
Licensed User
Longtime User
Also, the TextureVideoView example you provided won't install on my Galaxy S5 (Marshmallow.) It just says "X App not installed." But on my Motorola Moto 5 with Android 5.1, it works fine. Any idea what causes this?

Just for double check: Change the package name of sample code. I got the same problem many times because there is another app with package name b4a.example.
 

JS Hart

Member
Licensed User
Longtime User
Actually, though a screenshot would be nice, I don't really need it for the project. I would look to Vitamo, except that I do plan to commercialize this if it all goes as planned, and I think that the Vitamo license fees would make it cost prohibitive. But if there's a variable speed playback method in the works for VLC, that would be perfect. I'll just work on the project with full-speed playback till it becomes available.

As for the weird Galaxy S5 "not installed" thing, I'll see what I can turn up. It's probably simple...

Great, Thanks!
 

JS Hart

Member
Licensed User
Longtime User
Just for double check: Change the package name of sample code. I got the same problem many times because there is another app with package name b4a.example.
Thanks, I tried it, not the problem this time. I tried after re-downloading the example, and after rebooting the phone, no help. Another suggestion I turned up was to look for this file ".android_secure/smdl2tmpl.asec" and delete it, but it wasn't there...

I'll keep looking...
 
Top