Android Question SimpleExoPlayerView1 Get Tag value

MarcoRome

Expert
Licensed User
Longtime User
Hi, All.
I have this code:

B4X:
For ....
    clv_video.Add(CreateList(m.Get("titolo_filmato"), m.Get("filmato"), m.Get("punteggio"),  m.Get("costo"), m.Get("pagato") ,clv_video.AsView.Width, 300dip),"")
Next



Sub CreateList(titolo As String, filmato As String, punti As String, costo As String, pagato As Int, Width As Int, Height As Int) As Panel
    Dim p As Panel
    p.Initialize("")
    #if B4A
    p.SetLayout(0, 0, Width, Height)
    #else if B4i
        p.SetLayoutAnimated(0, 1, 0, 0, Width, Height) 'set the size before the layout is loaded
    #End If
        
    p.LoadLayout("lay_clv_video")
    lbl_titolo.Text = $"${titolo}"$
    lbl_punti.Text = $"Valore Video :${punti} punti"$
    
    If costo <> 0 And pagato <> 1 Then
        btn_acquista_video.Visible = True
        pnl_pagamento.Visible = True
        pnl_pagamento.Tag = "Pagamento"
    Else
        pnl_pagamento.Visible = False
        pnl_pagamento.Tag = "NON Pagamento"
    End If
    
                
    
    Private player1 As SimpleExoPlayer
    player1.Initialize("player")
    
    videoplayer.Add(CreateMap("player":player1))
    player1.Prepare(player1.CreateUriSource($"${Starter.variabile_video}${filmato}"$))
    SimpleExoPlayerView1.UseController = True
    SimpleExoPlayerView1.Tag = punti
    SimpleExoPlayerView1.Player = player1
    
    Return p
End Sub

Sub Player_Ready
    Log("Ready")
End Sub

Sub Player_Error (Message As String)
    Log("Error: " & Message)
End Sub

Sub Player_Complete
    Log("complete")
End Sub

The SimpleExoPlayer ( player1) object unfortunately does not have the tag property, otherwise i could fetch the same with the following code:


B4X:
Sub Player_Ready
    Log("Ready")
    Dim b As  SimpleExoPlayer
    b = Sender
    Log(b.tag)
End Sub

Any idea how can i get the Get value of the SimpleExoPlayerView1 object ?
Thank you
 

DonManfred

Expert
Licensed User
Longtime User
Any idea how can i get the Get value of the SimpleExoPlayerView1 object ?
Access the SimpleExoPlayerView1 and get it´s Tag instead of trying to get them from another Object (SimpleExoPlayer)?
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
Hi dear Don, the problem is that I have no events on the SimpleExoPlayerView1 object. So when i click on the specific object loaded on the clv, i have no way (sender) to access the SimpleExoPlayerView1.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is quite ugly:
B4X:
    Dim p As Panel
    p.Initialize("")
    #if B4A
    p.SetLayout(0, 0, Width, Height)
    #else if B4i
        p.SetLayoutAnimated(0, 1, 0, 0, Width, Height) 'set the size before the layout is loaded
    #End If

Correct code:
B4X:
Dim p As B4XView = XUI.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, Width, Height)

Check SMM for a very simple and cross platform way to play videos. It will also reuse the players for you. You don't want to create a new player for each item.

About the question, you will need to use a Map that maps between the player and the playerview.
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
Hi @Erel, thank you for your reply.

This is quite ugly:
Yes. You are right. It is a code from a few years ago

Check SMM for a very simple and cross platform way to play videos. It will also reuse the players for you. You don't want to create a new player for each item.
Right. I will try

About the question, you will need to use a Map that maps between the player and the playerview.

I did not understand this. after creating the map and passing the same, how can I get the value of a certain item, if I don't know the item.
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
B4X:
   SimpleExoPlayerView1.Player = player1
PlayersMap.Put(player1, SimpleExoPlayerView1)

Private Sub Player_Ready
 Dim p As SimpleExoPlayer = Sender
 Dim pv As SimpleExoPlayerView = PlayersMap.Get(p)

Yes, you're right as usual, it "escaped" :p me that i can insert objects in the map.
 
Upvote 0
Top