B4J Question play fullscreen video with text overlay

FrancescoS

Member
Licensed User
Longtime User
good morning everyone,
I am trying to play a movie in full screen and then I would like to write overlay text that change during playback (like subtitles).
I was able to playback the video but all the objects that I insert (ie label) seem to be behind the video and can't be seen.

Also I need to write 70% opacity text over the video.

here my code and a screenshot to better explain my goal:

fullscreen video example:
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show

    Dim jmf As JavaObject = MainForm
    Dim m As MediaPlayer
    Dim stage As JavaObject = jmf.GetField("stage")
    stage.RunMethod("setFullScreen", Array As Object(True))

    m.Initialize("m",File.GetUri("f:\","video_test.mp4"))
    stage.InitializeNewInstance("javafx.scene.media.MediaView",Array(m))
    MainForm.RootPane.AddNode(stage,0,0,1920,1080)

    m.Play

    Label1.Text="TEXT 1234"
    
end sub

Who can help me ?
thanks
Francesco
 

Attachments

  • video with text overlay.jpg
    video with text overlay.jpg
    35.3 KB · Views: 144

TILogistic

Expert
Licensed User
Longtime User
?
 
Upvote 0

FrancescoS

Member
Licensed User
Longtime User
thanks TILogistic, but I need full screen video without corner.
I have found a solution to show text:

video with text overlay:
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show

    Dim jmf As JavaObject = MainForm
    Dim m As MediaPlayer
    Dim stage As JavaObject = jmf.GetField("stage")
    stage.RunMethod("setFullScreen", Array As Object(True))

    m.Initialize("m",File.GetUri("f:\","video_test.mp4"))
    stage.InitializeNewInstance("javafx.scene.media.MediaView",Array(m))
    MainForm.RootPane.AddNode(stage,0,0,1920,1080)
    stage.RunMethod("toBack",Null)
    
    m.Play

    Label1.Text="TEXT 1234"
    
end sub

adding "stage.RunMethod("toBack",Null)" I can show and take control of text.
 
Upvote 0

FrancescoS

Member
Licensed User
Longtime User
Now I have another problem, when app starts, it display a message "press ESC to exit full screen mode".
Anybody knows how to disable this message ?
thanks
 

Attachments

  • screenshot_20230218_183156.png
    screenshot_20230218_183156.png
    511.1 KB · Views: 130
Upvote 0

FrancescoS

Member
Licensed User
Longtime User
Upvote 0

stevel05

Expert
Licensed User
Longtime User
As suggested in the link, try setting the hint to ""

B4X:
FormUtils.SetFullScreenExitHint(TestForm,"")

You will still need to set a key combination, but you can set it to something difficult to guess.

For instance:

B4X:
FormUtils.SetFullScreenExitKeyCombination(TestForm,FUtils_KeyCombinations.GetKeyCombination(Array As String(FUtils_KeyCombinations.KC_CONTROL,FUtils_KeyCombinations.KC_SHIFT,"!")))
 
Upvote 0

FrancescoS

Member
Licensed User
Longtime User
As suggested in the link, try setting the hint to ""

B4X:
FormUtils.SetFullScreenExitHint(TestForm,"")

You will still need to set a key combination, but you can set it to something difficult to guess.

For instance:

B4X:
FormUtils.SetFullScreenExitKeyCombination(TestForm,FUtils_KeyCombinations.GetKeyCombination(Array As String(FUtils_KeyCombinations.KC_CONTROL,FUtils_KeyCombinations.KC_SHIFT,"!")))
Thanks @stevel05 for your help !
 
Upvote 0
Top