Hi,
me again
I use a ScrollView where I can move a cursor in x,y direction and select the position to receive UDP video. Moving the cursor works always before the VideoView was called, after that the UP & DOWN Keyboard events are not consumed anymore (Activity_KeyPress) LEFT & RIGHT are still OK.
any ideas ?
THX
me again
I use a ScrollView where I can move a cursor in x,y direction and select the position to receive UDP video. Moving the cursor works always before the VideoView was called, after that the UP & DOWN Keyboard events are not consumed anymore (Activity_KeyPress) LEFT & RIGHT are still OK.
any ideas ?
THX
B4X:
Sub Process_Globals
End Sub
Sub Globals
Dim vv As VideoView
Dim sv As ScrollView
Dim panels(9, 50) As Panel
Dim Buttons(9,50) As Button
Dim back As Bitmap
Dim CurrentX As Int
Dim CurrentY As Int
Dim normalTransparent As ColorDrawable
Dim button_bg As BitmapDrawable
Dim Ph As Phone
Dim size As Int:size = 100
Dim ScreenFour As String: ScreenFour = "echo 2 >> /sys/class/video/screen_mode"
Dim ScreenSixt As String: ScreenSixt = "echo 3 >> /sys/class/video/screen_mode"
Dim ScreenAuto As String: ScreenAuto = "echo 0 >> /sys/class/video/screen_mode"
Dim play As Boolean ' dummy will go away
End Sub
Sub Activity_Create(FirstTime As Boolean)
play=False
back.Initialize(File.DirAssets,"Ara_bg.jpg")
Activity.SetBackgroundImage(back)
sv.Initialize(2000dip)
Activity.AddView(sv, 165,190, 900, 440)
normalTransparent.Initialize(Colors.ARGB(0,255,246,241), 0)
Dim bmp As Bitmap
For x = 0 To 8
For y = 0 To 14
bmp = LoadBitmap(File.DirAssets,Rnd(0,47)&".jpg")
Dim iv As Button
Dim p As Panel
iv.Initialize("Button")
iv.SetBackgroundImage(bmp)
iv.Gravity = Gravity.FILL
iv.Tag=((y*8)+ x + 1)
'iv.Text= ran
p.Initialize("PanelEvent")
sv.Panel.AddView(p, x * 100, y * 100, 100-10dip, 100-10dip)
'p.Color = Colors.aRGB(0,248,246,241)
p.AddView(iv, 5dip, 5dip, 100 - 20dip, 100 -20dip)
panels(x, y) = p
Buttons(x,y)=iv
Next
Next
ChangeSelection(0,0)
SetScreensize(ScreenSixt)
End Sub
Sub SetScreensize(ScreenSize As String)
Dim Command, Runner As String
Dim StdOut, StdErr As StringBuilder
Dim Result As Int
Dim Ph As Phone
StdOut.Initialize
StdErr.Initialize
Runner = File.Combine(File.DirInternalCache, "runner")
Command = File.Combine(File.DirInternalCache, "command")
File.WriteString(File.DirInternalCache, "runner", "su < " & Command)
File.WriteString(File.DirInternalCache, "command", ScreenSize & CRLF & "exit")
Result = Ph.Shell("sh", Array As String(Runner), StdOut, StdErr)
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'return true if you want to consume the event
Dim x, y,x1 As Int
x = CurrentX
y = CurrentY
Select KeyCode
Case KeyCodes.KEYCODE_DPAD_LEFT
x = x - 1
Case KeyCodes.KEYCODE_DPAD_RIGHT
x = x + 1
Case KeyCodes.KEYCODE_DPAD_DOWN
'x = x + 1
y = Min(y + 1, 50)
Case KeyCodes.KEYCODE_DPAD_UP
'x = x - 1
y = Max(y - 1, 0)
Case KeyCodes.KEYCODE_DPAD_CENTER
SelectChannel(x,y)
Case KeyCodes.KEYCODE_BACK
'If vv.IsInitialized Then
' vv.Stop
' vv.RemoveView
' play=False
'ChangeSelection(0,0)
Return True
'End If
Case 111 ' Test only
vv.Stop
vv.RemoveView
sv.ScrollPosition =0
End Select
Log ("my keycode " &KeyCode)
If x < 0 Then
x = 8
y = y - 1
If y < 0 Then
y=0
End If
Else If x > 8 Then
x = 0
If y < 14 Then
y = y + 1
End If
Else If y > 14 Then
y=14
End If
'If play=False Then
If x >= 0 AND x <= 8 Then ChangeSelection(x, y)
'End If
End Sub
Sub ChangeSelection(x As Int, y As Int)
panels(CurrentX, CurrentY).Color = Colors.aRGB(0,248,246,241)
CurrentX = x
CurrentY = y
panels(CurrentX, CurrentY).Color = Colors.RGB(255,0,0)'Colors.red
' label_Channel.Text=Buttons(CurrentX, CurrentY).Tag & " - "& ChName(Buttons(CurrentX, CurrentY).Tag-1)' .text & " - "&ran ' Fake Update Channel name
'check If need To scroll
If (y + 1) * size > sv.ScrollPosition + sv.Height Then
sv.ScrollPosition = sv.ScrollPosition + size
Else If (y * size) < sv.ScrollPosition Then
sv.ScrollPosition = sv.ScrollPosition - size
End If
End Sub
Sub SelectChannel(x As Int ,y As Int)
Dim b As Int
x=x+1
If vv.IsInitialized AND vv.IsPlaying Then
vv.RemoveView
End If
vv.Initialize("vv")
Activity.AddView(vv,0,0,100%x,100%y)
vv.MediaControllerEnabled=False
vv.LoadVideo("http","udp://239.0.0." & x &":1234")
vv.play
play =True
End Sub