如何使用 itents 在 android 中传递视频数据?

发布于 2024-11-23 17:47:31 字数 858 浏览 3 评论 0原文

好的活动 1 在 gridVideoView 中显示 SD 卡中的视频缩略图。我希望能够单击并将数据传递到活动 2 并播放这些视频。我买的书只告诉我如何用字符串来做到这一点。我该如何做到这一点,以便当我单击活动 1 中的视频时,它会被传递并可以在活动 2 中播放?如果您想要代码,我将发布它。

Intent Intent = new Intent(getBaseContext(), Editor.class); intent.putExtra("mnt/sdcard-ext", _ID); startActivity(intent);

       private VideoView video;
       private MediaController ctlr;
       File clip=new File(Environment.getExternalStorageDirectory(),
              "mnt/sdcard-ext");

      if (clip.exists()) {
      video=(VideoView)findViewById(R.id.video);
      video.setVideoPath(clip.getAbsolutePath());

       ctlr=new MediaController(this);
       ctlr.setMediaPlayer(video);
       video.setMediaController(ctlr);
       video.requestFocus();
       video.start();
      }
    }
 }

我如何在 VideoView 中引用意图?

Ok activity 1 displays thumbnails of videos from the SD card in a gridVideoView. I want to be able to click and pass the data onto activity 2 and play those videos. My book that i bought only shows me how to do this with strings. How can i do this so when i click a video in activity 1 it is passed and can be played in activity 2? If you would like the code I'll post it.

Intent intent = new Intent(getBaseContext(), Editor.class);
intent.putExtra("mnt/sdcard-ext", _ID);
startActivity(intent);

       private VideoView video;
       private MediaController ctlr;
       File clip=new File(Environment.getExternalStorageDirectory(),
              "mnt/sdcard-ext");

      if (clip.exists()) {
      video=(VideoView)findViewById(R.id.video);
      video.setVideoPath(clip.getAbsolutePath());

       ctlr=new MediaController(this);
       ctlr.setMediaPlayer(video);
       video.setMediaController(ctlr);
       video.requestFocus();
       video.start();
      }
    }
 }

How do i do reference the intent in the VideoView?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冬天旳寂寞 2024-11-30 17:47:31

一种选择是简单地将视频路径作为字符串传递给第二个活动。

One option would be to simply pass the path of the video as a string to the second activity.

真心难拥有 2024-11-30 17:47:31

试试这个:

Intent intentActionView = new Intent(Intent.ACTION_VIEW);
intentActionView.setDataAndType(pathToVideo, "video/*");
startActivity(intentActionView);

Try this:

Intent intentActionView = new Intent(Intent.ACTION_VIEW);
intentActionView.setDataAndType(pathToVideo, "video/*");
startActivity(intentActionView);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文