B4J Library MediaView - video player

1632902712566.png


This library includes two custom views: MediaView and MediaViewController.
MediaView can play local and remote videos and music.
The native JavaFX MediaView doesn't include a controller interface. I've implemented one. You can use it or create your own. Tip: the controller code and layout are inside the b4xlib file.

Usage:
Add the two custom views and connect them:
B4X:
MediaViewController1.SetMediaView(MediaView1)

Set the video source.
B4X:
MediaView1.Source = "https://player.vimeo....

Use File.GetUri to play a local file.

Tip: the simplest way to create a MediaView is with SimpleMediaManager: https://www.b4x.com/android/forum/threads/134716/#content

Updates


v1.03 - The MediaViewController class instance wasn't assigned to mBase.Tag correctly. This is fixed (https://www.b4x.com/android/forum/t...he-mediaviewcontroller-b4j.159864/post-981468)
v1.02 - Fixes an issue with setting the volume.
v1.01 - Fixes a layout issue.
 

Attachments

  • MediaViewExample.zip
    10.6 KB · Views: 588
  • MediaView.b4xlib
    4.9 KB · Views: 207
Last edited:

moster67

Expert
Licensed User
Longtime User
Tested it with a few different streaming links and it worked fine ?
Good job
 

CR95

Active Member
Licensed User
I tried it with avi files converted in mp4 by VLC
The MediaViewExample program starts but remains blocked on the first image of the video (note that the same file is red by VLC without problem)
Log error :
B4X:
Error: MediaException: UNKNOWN : [com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer@13d27beb] ERROR_MEDIA_INVALID: ERROR_MEDIA_INVALID

Please could you tell me what are the detailed formats supported by MediaView ?
And if you know an utility for converting avi.files to this standard ?
 

Star-Dust

Expert
Licensed User
Longtime User
Thanks @Erel.

I have a question: is it possible to change the audio device with MediaView? That is, if I have several sound cards, choose which one the sound should be output on?
 
Top