使用视频查看器的最佳方式。并播放视频

发布于 2024-12-02 02:52:52 字数 752 浏览 0 评论 0原文

有什么方法可以在不使用 uri 的情况下播放存储在原始文件中的视频。如果不是,我该如何正确设置 uri。假设我有一个名为电影的文件,我想用视频查看器播放它。我该怎么做?我还必须将数据写入 SD 卡吗?或者我可以直接从原始版本开始播放吗?

为什么我不能这样做

uri uri.parse("android.resources://"+this.getApplicationContext().getPackageName()+movie);

这就是我现在所拥有的,如果你可以的话,你可以向我指出错误,这样我就知道了,我不会再遇到这个问题了

          VideoView videoview = (VideoView) findViewById(R.id.videoView1);
          videoview.setKeepScreenOn(true);
          videoview.setVideoPath("android.raw://com.example.movievp8");
          MediaController controller = new MediaController(videoview.getContext()); 
          videoview.setMediaController(controller);           
          videoview.start();
          videoview.requestFocus();      

Is there any way I can play a video that has been stored in the raw file, without the use of the uri. If not how do i properly set the uri. Let's say i have file named movie and I want to play it with a videoviewer. How would i do this? Also would i have to write the data to the sd card. or can i just play it from the raw.

Why cant I just do

uri uri.parse("android.resources://"+this.getApplicationContext().getPackageName()+movie);

This is what I have it as now if you could can you point out the errors to me so i know and i wont have to have this problem any more

          VideoView videoview = (VideoView) findViewById(R.id.videoView1);
          videoview.setKeepScreenOn(true);
          videoview.setVideoPath("android.raw://com.example.movievp8");
          MediaController controller = new MediaController(videoview.getContext()); 
          videoview.setMediaController(controller);           
          videoview.start();
          videoview.requestFocus();      

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

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

发布评论

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

评论(1

指尖凝香 2024-12-09 02:52:52

这是对我有用的东西:

  videoResource = R.raw.some_video;
  String uri = String.format("android.resource://%s/%d", context.getPackageName(), videoResource);
  animationCanvas = (VideoView) ui.findViewById(R.id.animation_canvas);
  animationCanvas.setVisibility(View.VISIBLE);
  animationCanvas.setVideoURI(Uri.parse(uri));
  animationCanvas.setOnCompletionListener(this);
  animationCanvas.setOnPreparedListener(new OnPreparedListener() {
      public void onPrepared(MediaPlayer mp) {
          animationCanvas.start();

      }
  });

Here is something that works for me:

  videoResource = R.raw.some_video;
  String uri = String.format("android.resource://%s/%d", context.getPackageName(), videoResource);
  animationCanvas = (VideoView) ui.findViewById(R.id.animation_canvas);
  animationCanvas.setVisibility(View.VISIBLE);
  animationCanvas.setVideoURI(Uri.parse(uri));
  animationCanvas.setOnCompletionListener(this);
  animationCanvas.setOnPreparedListener(new OnPreparedListener() {
      public void onPrepared(MediaPlayer mp) {
          animationCanvas.start();

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