从json获取后如何查看和播放视频?

时间:2014-12-30 11:56:50

标签: android json android-videoview

我完全得到了json的响应,但我想显示我从json获取的视频文件,所有数据都是从json成功获得的,下面是我的json的响应,任何人都可以告诉我如何做到这一点??我正在使用videoview

{    
 "user_login_id":"2650",   
"user_total_video":"1",  
"max_upload_video":"1",  
"video_id":"487",  
"video_status":"Admin Approve Remaining",  
"video":"http:\/\/mywebss.com\/uploads\/user\/2650\/small\/Denger_But_Funny_Bomb_Blas(www.FunsMaza.in).3gp"  
 }

enter image description here

public class VideoList extends Activity{

private String User_IDs;
private String total;
private String max;
private String vidid;
private String vidsta;
private String vd;
private VideoView vides;
private ViewPager viewPager;
private ImageAdapter adapter;
private Button btnvideoupload;
private Button btndelete;


@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fullvideo);



    User_IDs=this.getIntent().getStringExtra("id");
    System.out.println("photo upload view user id"+User_IDs);

    total=this.getIntent().getStringExtra("totalvideos");
    System.out.println("photo total "+total);

    max=this.getIntent().getStringExtra("maxvideos");
    System.out.println("photo maximum "+max);

    vidid=this.getIntent().getStringExtra("videoid");
    System.out.println("photo maximum "+vidid);

    vidsta=this.getIntent().getStringExtra("vidstatus");
    System.out.println("photo maximum "+vidsta);

    vd=this.getIntent().getStringExtra("vids");
    System.out.println("photo maximum "+vd);

    btnvideoupload=(Button)findViewById(R.id.goforuploadvid);

    btnvideoupload.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent=new Intent(getApplicationContext(),VideoUpload.class);
            intent.putExtra("id", User_IDs);
            startActivity(intent);

        }
    });

    btndelete=(Button)findViewById(R.id.deletevid);
    btndelete.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

        }
    });

    /* viewPager = (ViewPager) findViewById(R.id.view_pager);
       adapter = new ImageAdapter(VideoList.this);
       viewPager.setAdapter(adapter);*/

    //Creating MediaController  
 MediaController mediaController= new MediaController(this);  
     mediaController.setAnchorView(vides);          

    vides=(VideoView)findViewById(R.id.videoviewfull);
    vides.setVideoURI(Uri.parse(vd.toString()));
    vides.setMediaController(new MediaController(VideoList.this));
    vides.requestFocus();
    vides.start();


       }

1 个答案:

答案 0 :(得分:0)

要从网址播放视频,您可以使用以下代码:

VideoView myVideoView = (VideoView)findViewById(R.id.myvideoview);
myVideoView.setVideoURI(Uri.parse("abcd.mp4"));
myVideoView.setMediaController(new MediaController(this));
myVideoView.requestFocus();
myVideoView.start();