B4J Question [B4J] SimpleMediaManager Video Controls Disappear After a Few seconds

William Lancee

Well-Known Member
Licensed User
Longtime User
1. How do I keep the controls visible.
2. Can I add << and >> icons? (Not part of this post, but if you know, why not)

B4X:
    videoPanel.Visible = True
    MediaManager.SetMediaFromFile(videoPanel, File.DirAssets, media, "video/*",  CreateMap(MediaManager.REQUEST_CALLBACK: Me))
    Wait For (videoPanel) SMM_MediaReady (Success As Boolean, mediax As SMMedia)
    Dim xx As B4XView = videoPanel.GetView(0).GetView(0)
    Dim playerview As MediaView = xx.Tag
    playerview.Play
 
Last edited:
Solution
You can use the built-in MediaViewController or you can create your own in the designer and save it as "MediaViewController".
You can find more information in the MediaViewController.bas file.
Here's some test code (not using SMM):
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private mv1 As MediaView
    Private mvc1 As MediaViewController
End Sub
Public Sub Initialize
    B4XPages.GetManager.LogEvents = True
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    mvc1.SetMediaView(mv1)
    mv1.Source = "https://player.vimeo.com/external/354886143.hd.mp4?s=2e182d1b22282a63a9533ffda5bb0b2295cdb8e6&profile_id=175"
    mv1.Volume = 1
    mvc1.FadeAfterMs =...

William Lancee

Well-Known Member
Licensed User
Longtime User
Here is a small demo that shows my problem - I would like all the controls (play progress speakers) to remain visible.
Attached .zip

B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    
    Private MediaManager As SimpleMediaManager
End Sub

Public Sub Initialize
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    MediaManager.Initialize
    
    Dim VideoPanel As B4XView = Root
    MediaManager.SetMediaWithExtra(VideoPanel, "https://player.vimeo.com/external/354886143.hd.mp4?s=2e182d1b22282a63a9533ffda5bb0b2295cdb8e6&profile_id=175", "video/*",  _
            CreateMap(MediaManager.REQUEST_CALLBACK: Me))
    Wait For (VideoPanel) SMM_MediaReady (Success As Boolean, mediax As SMMedia)
    Dim xx As B4XView = VideoPanel.GetView(0).GetView(0)
    Dim playerview As MediaView = xx.Tag
    
    Sleep(1000) 'to start after 1 second delay for testing purposes
    playerview.Play
    Dim controls As B4XView = VideoPanel.GetView(0).GetView(1).GetView(0).GetView(0)
    For i = 0 To 100
        Log(controls.Visible)
        Sleep(1000)
    Next
    
    'True
    'True
    'True        'after 3-4 seconds controls disappear
    'False
    'False

End Sub
 

Attachments

  • testSMM.zip
    7.6 KB · Views: 14
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
1. How do I keep the controls visible.
2. Can I add << and >> icons? (Not part of this post, but if you know, why not)
For what you want you must modify.

1.- MediaViewController.bas (Timer1_Tick)
2.- If possible, add the logic in MediaView.bas (javaobject) and mediaViewController.bas (controller << and >> )

ref:
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
eje.
1729743305872.png


This is an example, you can fast forward and rewind the video, and I have enabled the controls to appear when the mouse is positioned over the video, or to remain fixed, through a parameter,
MediaViewController1.SetOnMouseOverVideo = True
and other options for video quality, subtitles, etc.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Upvote 0

PaulMeuris

Active Member
Licensed User
You can use the built-in MediaViewController or you can create your own in the designer and save it as "MediaViewController".
You can find more information in the MediaViewController.bas file.
Here's some test code (not using SMM):
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private mv1 As MediaView
    Private mvc1 As MediaViewController
End Sub
Public Sub Initialize
    B4XPages.GetManager.LogEvents = True
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    mvc1.SetMediaView(mv1)
    mv1.Source = "https://player.vimeo.com/external/354886143.hd.mp4?s=2e182d1b22282a63a9533ffda5bb0b2295cdb8e6&profile_id=175"
    mv1.Volume = 1
    mvc1.FadeAfterMs = 1000000000
End Sub
Private Sub mv1_StateChanged (State As String)
    If State = "PLAYING" Then
        mvc1.mBase.Visible = True
    End If
End Sub
Setting the FadeAfterMs to a very high number will keep the MediaControllerView visible for days (1000000 seconds)...
It's best to set the color of the MediaView to black.
 
Upvote 0
Solution

William Lancee

Well-Known Member
Licensed User
Longtime User
@TILogistic I couldn't find MediaViewController.bas to modify.
And...would it be possible to look at your modified version?

@PaulMeuris As usual, you come to the rescue quickly and efficiently.
These two lines solve the persistent controls issue.
I'll mark this is the Solution to my question.

[When I find MediaViewController.bas, I'll look at adding the << and >> controls.

B4X:
    Dim mvc As MediaViewController = videoPanel.GetView(0).GetView(1).Tag
    mvc.FadeAfterMs = 360000000     '<== Keeps controls visible for 100 minutes
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
In case someone is looking for this..
An easy way of adding the toStart (|<<) and toEnd (>>|) icons is to add them to the overlay panel of the MediaViewController.
B4X:
    Dim playerview As MediaView = videoPanel.GetView(0).GetView(0).Tag
    playerview.Volume = 0
    playerview.Play
    Dim mvc As MediaViewController = videoPanel.GetView(0).GetView(1).Tag
    mvc.FadeAfterMs = 3600000000     '<== Keeps controls visible for 1000 minutes
   
    Dim topPanel As B4XView = mvc.Overlay

    Dim lblx As B4XView = addControl("ToStart", Chr(0xF049), "LEFT")
    lblx.Tag = playerview
    topPanel.AddView(lblx, mvc.pnlBottom.Left + 65, mvc.pnlBottom.Top - mvc.pnlBottom.Height, 40, 40)

    Dim lblx As B4XView = addControl("ToEnd", Chr(0xF050), "RIGHT")
    lblx.Tag = playerview
    topPanel.AddView(lblx, mvc.pnlBottom.Left + mvc.pnlBottom.Width - 55, mvc.pnlBottom.Top - mvc.pnlBottom.Height, 40, 40)

Capture the click event (and consume it).

B4X:
Private Sub ToStart_MouseClicked(Ev As MouseEvent)
    Dim lblx As B4XView = Sender
    Dim mv As MediaView = lblx.tag
    mv.Position = 0
    Ev.Consume
End Sub

Private Sub ToEnd_MouseClicked(Ev As MouseEvent)
    Dim lblx As B4XView = Sender
    Dim mv As MediaView = lblx.tag
    mv.Position = mv.Duration
    Ev.Consume
End Sub

(The attached video is a bit fuzzy, since I had to reduce it to upload here)
SMMControls_NEW.jpeg
 
Upvote 0

PaulMeuris

Active Member
Licensed User
@William Lancee , thank you for your kind words. Sorry i forgot to mention the library name.
A fast forward or fast backwards (10 seconds or 30 seconds) would also be nice to have...
And everything on one line and a full screen button (like in the example from @TILogistic ) would also look good...
You can see a full screen action in my pmfiles tutorial: follow the link in my signature.
 
Upvote 0
Top