我正在执行获取请求以从服务器获取数据.Json属性之一具有一个iframe,当我将其放在我的android应用程序的videoView上时,它说视频播放器已停止。该属性的值是一个字符串。这是错误。
无法开启
<iframe src='https://www.scorebat.com/embed/g/814210/?s=2' frameborder='0' width='560' height='590'...>
这是我在Adapter类上尝试过的
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
AirlineListItem listItem = listItems.get(position);
holder.airlineId.setText(listItem.getTitle());
holder.codeIataAirline.setVideoURI(Uri.parse(listItem.getEmbed()));
}
这是我在MainActivity中的方法
private void getData() {
final ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Loading...");
progressDialog.show();
JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(URL_DATA, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
for (int i = 0; i < response.length(); i++) {
try {
JSONObject jsonObject = response.getJSONObject(i);
AirlineListItem airline = new AirlineListItem();
airline.setTitle(jsonObject.getString("title"));
//this is the <iframe>
airline.setEmbed(jsonObject.getString("embed"));
listItems.add(airline);
} catch (JSONException e) {
e.printStackTrace();
progressDialog.dismiss();
}
}
adapter.notifyDataSetChanged();
progressDialog.dismiss();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e("Volley", error.toString());
progressDialog.dismiss();
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> params = new HashMap<String, String>();
params.put("x-rapidapi-host", "");
params.put("x-rapidapi-key", "");
return params;
}
};
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(jsonArrayRequest);
}