Troubleshooting guide

59
2: Using graphics and multimedia
...
break;
}
break;
...
switch(s.getStatus()) {
case LoadingStatus.LOADING_STARTED:
System.out.println("Loading in progress");
break;
case LoadingStatus.LOADING_READING:
System.out.println("Parsing in progress");
break;
case LoadingStatus.LOADING_FINISHED:
System.out.println("Loading completed");
break;
case LoadingStatus.LOADING_FAILED:
String errorName = null;
int code = s.getCode();
switch (code) {
case MediaException.INVALID_HEADER:
errorName = "Invalid header" + "\n" + s.getSource();
break;
case MediaException.REQUEST_TIMED_OUT:
errorName = "Request timed out" + "\n" +
s.getSource();
break;
case MediaException.INTERRUPTED_DOWNLOAD:
break;
case MediaException.UNSUPPORTED_TYPE:
errorName = "Unsupported type" + s.getMessage() + "\n" + s.getSource();
break;
default: {
if (code > 200) {
// A code > 200 indicates an HTTP error
errorName = "URL not found";
} else {
// default unidentified error
errorName = "Loading Failed";
}
errorName += "\n" + s.getSource() + "\n" + s.getCode()
+ ": " + s.getMessage();
break;
}
}
System.out.println(errorName);
break;
} // End switch s.getStatus().
break;
}
Code sample: Implementing a listener to download rich media content
The MediaSample2.java code sample implements a listener to download media content in the background and
display the download status to the console.