Hello,
how do I catch the clickitems of the Exoplayer when it's placed on the clv?
It seems the player buttons are not catched.
What I want is that other players stop when a player is started, now they just play thru each other.
I also tried the expandable_clv in another project and with that you can use the status of the expanded item to stop another player,
except when 2 or 3 are expanded then multiple players can play at once which I don't want.
For this project the players are put under each other and the nr of players depend on how many music tracks there are in an album.
Trying to test some things which gave no result yet:
Does anyone have a idea how to solve this? I searched but could not find an answer, nor that it was asked before.
Many Thanks for any help!
how do I catch the clickitems of the Exoplayer when it's placed on the clv?
It seems the player buttons are not catched.
What I want is that other players stop when a player is started, now they just play thru each other.
I also tried the expandable_clv in another project and with that you can use the status of the expanded item to stop another player,
except when 2 or 3 are expanded then multiple players can play at once which I don't want.
For this project the players are put under each other and the nr of players depend on how many music tracks there are in an album.
B4X:
Sub FillCLV
Log("start FillCLV")
clv1.Clear
TrkImage.Initialize("")
Dim sources1 As List
sources1.Initialize
''''''playerJ.Prepare(playerJ.CreateListSource(sources1))
Dim trackpic As String
If albumtrackpics.IsInitialized Then
Log("albumtrackpics= " & albumtrackpics.Get(0))
For i = 0 To albumtrackpics.Size -1
trackpic = albumtrackpics.Get(i)
Log("trackpic= " & trackpic)
'''''playerJ.Initialize("playerJ")
playerJ.Prepare(playerJ.CreateListSource(sources1))
Dim p1 As B4XView = CreateItem((0xFF000000), TrkImage, playerJ)
clv1.Add(p1,"")
Dim tr As Int
tr = i + 1 'there is no 0.mp3 so add 1
DownloadImage(trackpic, TrkImageView) 'correct name is in albumtrackpics.Get(i)
sources1.Add(playerJ.CreateUriSource("https://trackshere.com/albumtracks/" & albumnamempthree & "/" & tr & ".mp3"))
Next
End If
End Sub
B4X:
Sub CreateItem(clr As Int, trkimg As ImageView, player As B4XView) As B4XView
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, clv1.AsView.Width,260dip) ', clv1.AsView.Height)
p.LoadLayout("clvfront")
TrkImageView.Bitmap = trkimg.Bitmap
SimpleExoPlayerView1.Player = player
SimpleExoPlayerView1.Tag = player
'SimpleExoPlayerView1.ControllerTimeout = -1
'SimpleExoPlayerView1.RemoveView
'SimpleExoPlayerView1.UseController = False
VideoPlayers.Put(SimpleExoPlayerView1, True)
Dim jo As JavaObject = SimpleExoPlayerView1 'this stops controlbuttons from fading away on player
jo.RunMethod("setControllerShowTimeoutMs", Array(0))
jo.RunMethod("setControllerHideOnTouch", Array(False)) 'this line prevents remove of controls, when touch on outer left or right side
Return p
End Sub
B4X:
Sub clv1_ItemClick (Index As Int, Value As Object)
Log("Clicked on clv1")
Try
'AdWebView.SendToBack
Log("index: " & Index & "Value: " & Value)
Dim MyVal As String = Value
Dim item() As String = Regex.Split(",", MyVal)
Log("item " & item(0)) 'this show Expanded=false or Expanded=True
Dim JaNee As String = item(0)
Dim TF() As String = Regex.Split("=", JaNee)
Log("TF: " & TF(0))
Dim components() As String
components = Regex.Split("=", item(0)) 'returns: "abc", "def", "", "ghi"
Log ("components: " & components(0))
Dim tbState As Boolean
If components(0) = "true" Then
tbState = True
Else
tbState = False
End If
Private id As Int
id = Index' + 1
'If id = 0 And tbState = True Then
If id = 0 Then
playerJ.Pause
End If
Catch
Log("itemclickerror: " & LastException.Message)
End Try
End Sub
Trying to test some things which gave no result yet:
B4X:
Sub SimpleExoPlayerView1_Click
Log(SimpleExoPlayerView1_ItemClick)
Log(SimpleExoPlayerView1_Click)
End Sub
Private Sub Music_Click
Log(Music_Click)
Log(MusicBtn)
End Sub
Private Sub VideoClips_Click
Log(VideoClips_Click)
Log(VideoClipsBtn)
Log(VideoPlayers)
End Sub
Sub Player_ItemClick (Index As Int, Value As Object)
Log("playerIndex: " & Index)
Log("playerValue: " & Value)
End Sub
Does anyone have a idea how to solve this? I searched but could not find an answer, nor that it was asked before.
Many Thanks for any help!