zoukankan      html  css  js  c++  java
  • android如何播放音视频【原】

    // 选取视频按钮单击事件
     public void click_xuanqushipin(View source) {

      Intent intent = new Intent();
      /* 开启Pictures画面Type设定为image */
      intent.setType("video/*");
      /* 使用Intent.ACTION_GET_CONTENT这个Action */
      intent.setAction(Intent.ACTION_GET_CONTENT);
      /* 取得相片后返回本画面 */
      startActivityForResult(intent, 3);

     }

    @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      // 选取音频的返回值
      if (requestCode == 2) {
       //
       if (resultCode == RESULT_OK) {
        Uri uri = data.getData();
        //
        // toast = Toast.makeText(getApplicationContext(), "图片标题不能为空!",
        // Toast.LENGTH_LONG);
        // toast.setGravity(Gravity.CENTER_HORIZONTAL, 0, 0);
        // toast.show();
        //
        Cursor cursor = getContentResolver().query(uri, null, null,
          null, null);
        cursor.moveToFirst();
        // String imgNo = cursor.getString(0); // 图片编号
        gj.imgPath = cursor.getString(1); // 图片文件路径
        String imgName = cursor.getString(2); // 图片文件名
        String imgSize = cursor.getString(3); // 图片大小

        gj.fileName = imgName;
        gj.fileSize = imgSize;
        // Log.e("uri", uri.toString());
        ContentResolver cr = this.getContentResolver();
        try {
         // 尝试将音频文件 赋值给videoView
         //
         final MediaController mediaController = new MediaController(this);
         VideoView videoView = (VideoView) findViewById(R.id.videoView1);
         videoView.setMediaController(mediaController);
         //videoView.setVideoPath(gj.imgPath);
         videoView.setVideoURI(uri);
         videoView.requestFocus();
         videoView.start();

         
        } catch (Exception e) {
         // TODO: handle exception
        }
       }
      }

    }

  • 相关阅读:
    2017加油
    配置SSH框架的心得
    .net 中select和where的区别
    oracle查询中文数据出现乱码
    three.js 加载 obj模型
    下载别人的3D模型文件
    关闭按钮
    桌面截屏保存成gif形式(软件)
    vue 中引入 three.js
    three.js-地球贴图-TextureLoader
  • 原文地址:https://www.cnblogs.com/zhwl/p/2134899.html
Copyright © 2011-2022 走看看