Android Question CCTV Client MJPEG Class Not Working with string variable

Discussion in 'Android Questions' started by Juan Marrero, Aug 15, 2018.

  1. Juan Marrero

    Juan Marrero Active Member Licensed User

    Hi. I tried using MJPEG Class in B4A (copied from B4J example and modified to B4A) with a string written directly
    Code:
    mj1.Connect("192.168.0.5/"51042)
    and it's working. But if I store that same string in a variable
    Code:
    Dim ip as String = "192.168.0.5/"
    mj1.Connect(ip, 
    51042)
    Is not working. It just displays a blank screen, no error.
    Any help is appreciated.
    mj1 is defined in process_globals as MJPEG
    and this is the Frame Sub
    Code:
    Sub mj1_Frame(bmp as Bitmap)
        ImageView1.Bitmap = bmp
    End Sub
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    It doesn't matter where the string comes from. I can only guess that in the second case there was an extra space or something similar.
     
  3. Juan Marrero

    Juan Marrero Active Member Licensed User

    I used inputdialog for it from Dialogs Library. When input is returned I compared it like this for testing purposes:
    Code:
    Dim ip as String = "192.168.0.5/"

    If ip = "192.168.0.5/" Then
        mj1.Connect(
    "192.168.0.5/"51042)
    End If
    And it entered the If Statement.

    Code:
    Dim input As InputDialog
      
    input.InputType = input.INPUT_TYPE_TEXT
    Dim ans As Int = input.Show("Enter Server IP:""IP""OK""""Cancel"Null)
    Dim ip As String
     
    If ans = DialogResponse.POSITIVE Then
        ip = input.Input
    End If

    If ip = "192.168.0.5/" Then
        mj1.Connect(
    "192.168.0.5/"51042)
    End If
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    As I said, it doesn't matter where the string comes from.
     
  5. Juan Marrero

    Juan Marrero Active Member Licensed User

    Ok. For some reason is not working for me. I'll have to dig more. Thanks. I solved it using a hotspot and I know that Android's default IP is 192.168.43.1 I used it directly in code.
     
  6. jimmyF

    jimmyF Active Member Licensed User

    Try dropping the '/' from the end of the IP address.
    The app concatenates the ip and the port so you may end up with this:

    192.168.0.5/:51042 which is incorrect.

    Just a thought.

    -j
     
  7. Juan Marrero

    Juan Marrero Active Member Licensed User

    Dropping the '/' gives me the following error: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
     
  8. jimmyF

    jimmyF Active Member Licensed User

    What jdk are you using?
     
  9. Juan Marrero

    Juan Marrero Active Member Licensed User

    1.8.0_xxx
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice