我从我的数据库获得的链接与我的S3存储桶上的视频相关联,但每次尝试播放时,都会返回(1,-2147483648)
public static ExploreFragment create(int pageNumber) {
ExploreFragment fragment = new ExploreFragment();
Bundle args = new Bundle();
args.putInt(ARG_PAGE, pageNumber);
fragment.setArguments(args);
return fragment;
}
public ExploreFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout containing a title and body text.
ViewGroup rootView = (ViewGroup) inflater
.inflate(R.layout.fragmentlayout, container, false);
vv1 = (SurfaceView) rootView.findViewById(R.id.VideoView1);
holder = vv1.getHolder();
holder.addCallback(this);
mp = new MediaPlayer();
try {
mp.setDataSource(links.get(getPageNumber()).trim());
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mp.setOnPreparedListener(this);
mp.prepareAsync();
mp.start();
return rootView;
“links”只是一个列表,其中包含我需要在ViewPager上显示的所有来自cloudfront的链接。
这是提取内容的AsyncTask:
class PullContent extends AsyncTask<Void,Void,String> {
public ArrayList<String> list = new ArrayList<String>();
public ArrayList<String> linklist = new ArrayList<String>();
public static ArrayList<ArrayList<String>> listoflists = new ArrayList<ArrayList<String>>();
public static String[] array;
@Override
protected String doInBackground(Void... params) {
/*if(Long.parseLong(Constants.EXPIRATION_DATE) < System.currentTimeMillis() + 15*60*100){
new TokenRequest().execute(Constants.SECRETKEY_LOGIN);
}*/
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response;
try {
response = httpclient.execute(new HttpPost("http://davai.co/getkremlin"));
InputStreamReader SearchReader = null;
try {
SearchReader = new InputStreamReader(response.getEntity().getContent());
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
BufferedReader ObjBuffer = new BufferedReader(SearchReader);
String line = "";
try {
while((line = ObjBuffer.readLine())!= null){
list.add(line.trim());
if(list.size() == 2){
listoflists.add(list);
linklist.add(list.toString());
list.clear();
}
}
ExploreFragment.checked = true;
getContent(linklist);
} catch (IOException e) {
Log.i("exception", "exception");// TODO Auto-generated catch block
e.printStackTrace();
}
}
catch(Exception exception){
Log.i("exception", exception.getMessage());
return null;
}
return null;
}
public void onPostExecute(String result){
}
private void getContent(ArrayList<String> linklist) {
if(linklist.size()>0){
// TODO Auto-generated method stub
for(String str:linklist){
int indexofOpen = str.indexOf("[");
int indexofClose = str.lastIndexOf("]");
String res = str.substring(indexofOpen+1,indexofClose);
String[] resarray = res.split(",");
ExploreFragment.usernames.add(resarray[0].trim());
ExploreFragment.links.add(resarray[2]);
ExploreFragment.locations.add(resarray[3]);
ExploreFragment.times.add(resarray[1]);
}
}else{
new AlertDialogFrag();
}