B4J Code Snippet [FREE] New custom version of Mediaview library version 1.04 now available for download

New custom display version of MediaView and MediaController.

It is compatible with Simple Media Manager (SMM).

1733854292103.png


1733854405445.png


Library (b4xlib) attached for use, download in additional B4J libraries

Library: jMediaView.b4xlib
Example: MediaView.zip

1733854822882.png


B4X:
'    ***********  MediaViewController ***********

    'Example 1  
    MediaViewController1.SetBackgroundColor = xui.Color_ARGB(190,0,0,0)
    MediaViewController1.SetTextIconColor = xui.Color_White
   
    'Example 2
'    Dim Colors() As Int = Array As Int(xui.Color_Black, xui.Color_White)
'    MediaViewController1.SetBackgroundColorGradient(Colors, "BOTTOM_TOP")
'    MediaViewController1.SetTextIconColor = xui.Color_Black

    MediaViewController1.SetOnMouseOverVideo = True
   
'    ***********  MediaView ***********
   
    MediaView1.SetBackgroundColor = xui.Color_Black
    MediaView1.SetPreserveRatio = False

'    ***********  Visualize ***********

'   Video
    Dim VideoURL As String = "https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8"

    MediaViewController1.SetMediaView(MediaView1)
    MediaView1.Source = VideoURL
    MediaView1.Play

Regards.
 

Attachments

  • jMediaView.b4xlib
    6.5 KB · Views: 254
  • MediaView.zip
    3.2 KB · Views: 250
Last edited:

T201016

Active Member
Licensed User
Longtime User
I wonder if the view of MediaController disappears after a fixed time?
 

T201016

Active Member
Licensed User
Longtime User
Mediaview for B4J is now available for download. If you have any queries, please post them in this post.
Hi, @TILogistic
I have a question about changing the titlebar. Is it possible to be able to change the color of the titlebar? I am referring to my post and the query it contains.
See:
 

TILogistic

Expert
Licensed User
Longtime User
I checked your post, and @stevel05 already provided the solution.

As for my solution, I created an application bar that I use in B4X (cross-platform) and that I can configure with the icon, title, subtitle, action icons, menu items, etc.

As you can see, I don't use the title bars, but a custom one.
 

ganezha

Member
New custom display version of MediaView and MediaController.

It is compatible with Simple Media Manager (SMM).

View attachment 159400

View attachment 159401

Library (b4xlib) attached for use, download in additional B4J libraries

Library: jMediaView.b4xlib
Example: MediaView.zip

View attachment 159402

B4X:
'    ***********  MediaViewController ***********

    'Example 1 
    MediaViewController1.SetBackgroundColor = xui.Color_ARGB(190,0,0,0)
    MediaViewController1.SetTextIconColor = xui.Color_White
  
    'Example 2
'    Dim Colors() As Int = Array As Int(xui.Color_Black, xui.Color_White)
'    MediaViewController1.SetBackgroundColorGradient(Colors, "BOTTOM_TOP")
'    MediaViewController1.SetTextIconColor = xui.Color_Black

    MediaViewController1.SetOnMouseOverVideo = True
  
'    ***********  MediaView ***********
  
    MediaView1.SetBackgroundColor = xui.Color_Black
    MediaView1.SetPreserveRatio = False

'    ***********  Visualize ***********

'   Video
    Dim VideoURL As String = "https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8"

    MediaViewController1.SetMediaView(MediaView1)
    MediaView1.Source = VideoURL
    MediaView1.Play

Regards.


Modify button ratio for full screen mode
 

Attachments

  • jMediaView.b4xlib
    6.5 KB · Views: 22

TILogistic

Expert
Licensed User
Longtime User
Modify button ratio for full screen mode
I don't understand your solution

B4X:
Private Sub lblRatio_MouseClicked (EventData As MouseEvent)
    'mMediaView.SetPreserveRatio = Not(mMediaView.GetPreserveRatio)
        CallSub2(Main, "setFullscreen", True)
    'EventData.Consume
End Sub

I should call or add another full-screen icon.
 

TILogistic

Expert
Licensed User
Longtime User
or call
B4X:
SetFullScreen(True, "Press CTRL+E to exit full screen", "E")

B4X:
Public Sub SetFullScreen (Status As Boolean, Message As String, KeyControl As String)
    FormUtils.SetFullScreen(B4XPages.GetNativeParent(Me),Status)
    FormUtils.SetFullScreenExitHint(B4XPages.GetNativeParent(Me), Message)
    FormUtils.SetFullScreenExitKeyCombination(B4XPages.GetNativeParent(Me),FUtils_KeyCombinations.GetKeyCombination(Array As String(FUtils_KeyCombinations.KC_CONTROL,KeyControl)))
End Sub

use:

NOTE:
This shows the full screen of the form where only this media player is located.

test:
add:

B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    B4XPages.SetTitle(Me, "MediaView Example")
    Root = Root1
    Root.LoadLayout("MainPage")

    SetFullScreen(True, "Press CTRL+E to exit full screen", "E")
   
'    ***********  MediaViewController ***********

function:
B4X:
Public Sub SetFullScreen (Status As Boolean, Message As String, KeyControl As String)
    FormUtils.SetFullScreen(B4XPages.GetNativeParent(Me),Status)
    FormUtils.SetFullScreenExitHint(B4XPages.GetNativeParent(Me), Message)
    FormUtils.SetFullScreenExitKeyCombination(B4XPages.GetNativeParent(Me),FUtils_KeyCombinations.GetKeyCombination(Array As String(FUtils_KeyCombinations.KC_CONTROL,KeyControl)))
End Sub
 
Last edited:

ganezha

Member
I don't understand your solution

B4X:
Private Sub lblRatio_MouseClicked (EventData As MouseEvent)
    'mMediaView.SetPreserveRatio = Not(mMediaView.GetPreserveRatio)
        CallSub2(Main, "setFullscreen", True)
    'EventData.Consume
End Sub

I should call or add another full-screen icon.
This is sample code for FullScreen
 

Attachments

  • JMediaView.rar
    5 KB · Views: 13

TILogistic

Expert
Licensed User
Longtime User
This is sample code for FullScreen

As I mentioned before, your solution only creates a full-screen view of the form. As I explained earlier, you're using the icon that fills the video in the container (SetPreserveRatio), which is false by default.

What would happen if you had two or more JMediaView objects in a form?

For a better solution, add an icon with an event to the class that creates a full-screen view of the form containing only one JMediaView, or simulate full-screen mode, as ExoPlayer does.

As I mentioned before, your solution only creates a full-screen view of the form. As I explained earlier, you're using the icon that fills the video in the container (SetPreserveRatio), which is false by default.

What would happen if you had two or more JMediaView objects in a form?

For a better solution, add an icon with an event to the class that creates a full-screen view of the form containing only one JMediaView, or simulate full-screen mode, as ExoPlayer does.

Also, your solution creates a full-screen view of the main form (B4XMainPage). What would happen if I added it to a new form?

you solution: form main:
B4X:
Private Sub setFullscreen(value As Boolean)
    Dim jmf As JavaObject = MainForm
    Dim stage As JavaObject = jmf.GetField("stage")

    stage.RunMethod("setFullScreen", Array As Object(value))
End Sub
 

TILogistic

Expert
Licensed User
Longtime User
!! And please start a new thread with your solutions or questions. !!

I'll be posting more UI and video improvements soon.
 
Top