Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void getVideo(final String videoID, final String nameVideo){
- client.cancelRequests(mContext, true);
- client = new AsyncHttpClient();
- /// String video_id = "1FJHYqE0RDg";
- String video_id = "";
- String gdata = "http://gdata.youtube.com/feeds/api/videos/";
- String urlrequest = "";
- // MyLog.E("url before>>>" + url);
- // if(url.contains("youtube.com")){
- // video_id = url.split("v=")[1];
- // urlrequest = gdata+video_id;
- // urlrequest = url;
- urlrequest = "http://www.youtube.com/watch?v="+videoID;
- client.setUserAgent("Mozilla/5.0 (iPad; CPU OS 6_0_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A523 Safari/8536.25");
- MyLog.E("urlrequest youtube>>>" + urlrequest);
- // }
- // else{
- // urlrequest = String.format(String.valueOf(MyConstans.API_PHIMDETAIL),obj.VideoId,url);
- // MyLog.E("url phimdetail>>>" + urlrequest);
- // }
- if(myUtil.isInternet(mContext))
- client.get(urlrequest, new AsyncHttpResponseHandler() {
- @Override
- public void onStart() {
- // TODO Auto-generated method stub
- super.onStart();
- // progressLoading.setVisibility(View.VISIBLE);
- }
- @Override
- public void onSuccess(int arg0, String arg1) {
- // TODO Auto-generated method stub
- super.onSuccess(arg0, arg1);
- // progressLoading.setVisibility(View.GONE);
- // btnPlayPhim.setVisibility(View.VISIBLE);
- MyLog.E("phimdetail>>>" + arg1);
- try {
- Intent i = new Intent(mContext,WatchActivity.class );
- // if(url.contains("youtube.com")){
- // String rtsp_link = "rtsp:"+ MyUtil.split(MyUtil.split(arg1, "rtsp:")[1], ".3gp")[0] + ".3gp";
- String rtsp_link =MyUtil.getYoutubeRespond(arg1);
- MyLog.E("rtsp_link>>>" + rtsp_link);
- i.putExtra("URLPLAY", rtsp_link);
- // }
- // else{
- // MyLog.E("caption>>>" + arg1);
- // String strCode = myUtil.getUrlVideo(arg1);
- // i.putExtra("URLPLAY", strCode);
- // }
- i.putExtra("FILM_NAME", nameVideo);
- i.putExtra("LINK_SUB", "DM sub");
- mContext.startActivity(i);
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- }
- }
- @Override
- protected void sendFailureMessage(Throwable arg0, String arg1) {
- // TODO Auto-generated method stub
- super.sendFailureMessage(arg0, arg1);
- }
- });
- else
- Toast.makeText(mContext, "Lỗi kết nối mạng", Toast.LENGTH_SHORT).show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment