1
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class UIpopulator : MonoBehaviour {

public GameObject[] Recentthumb;
public GameObject featuredThumb;
//public GameObject videoThumb;
jsonparse jp;
public Text uu;
// Use this for initialization
void Start()
{

}
public IEnumerator changeText(int i,RawImage img)
{
    jp = GetComponent<jsonparse>();
    // Start a download of the given URL
    WWW www = new WWW(jp.turl[i]);
    // Wait for download to complete
    yield return www;
    if (www.error == null)
    {
        uu.text = "success";
        img.texture = www.texture;

    }
    else
    {
        uu.text = www.error;
    }
    img.GetComponent<videoUrl>().setUrl(jp.vurl[i]);

}



void setRecentThumb()
{
    int i = jsonparse.videoCount;
    StartCoroutine(changeText(i - 1, Recentthumb[0].GetComponent<RawImage>()));
    StartCoroutine(changeText(i - 2, Recentthumb[1].GetComponent<RawImage>()));
}
void setFeatured()
{
    int i = jsonparse.videoCount;
    StartCoroutine(changeText(0, featuredThumb.GetComponent<RawImage>()));
}

public void UiSetup()
{
    setRecentThumb();
    setFeatured();
}  

}

the above code runs fine in the editor itself but gives but it gives the following error on android device

enter image description here

this is the url from where I am getting the json file

http://192.168.0.5/chillivr/wp-content/content/vid.json

WWW.text seems to work fine on android as I am getting all the urls on the device. the problem occurs when I try to get the png image.

I am using xampp on desktop

thank you.

  • Is your phone connected to the same network? 192.168.0.5 is a local IP to your local network. You phone needs to be connected to the same network to be able to reach it. – Fredrik Schön Feb 28 '17 at 13:19
  • yes.. phone is connected to the same network – Akash Gajbhiye Feb 28 '17 at 13:21
  • 1
    http://stackoverflow.com/questions/6876266/java-net-connectexception-connection-refused – Fredrik Schön Feb 28 '17 at 13:35
  • Did you check that thread? Also, if you open a browser on your phone and go to http://192.168.0.5/chillivr/wp-content/content/vid.json, does it work or are you getting refused? You might need to specify the port if the browser sets the default port for you. – Fredrik Schön Feb 28 '17 at 13:36
  • I can access all the contents using the browser on my mobile device everything works fine.. I also tried uploading the files on my wordpress blog which is online and then access it .. then also the code works fine in unity editor but same error is shown on mobile device.. so I am sure that the problem is not with port – Akash Gajbhiye Feb 28 '17 at 13:52
  • Any solution to this? My WebGL and iOS builds work fine but my Android one just instantly gives 'connection refused' – MingMan May 15 '17 at 16:39

0 Answers0