Android-媒体播放器

发布于 2024-09-19 02:04:36 字数 1186 浏览 9 评论 0原文

我是安卓新手。我正在尝试播放 SD 卡上的视频。

这是我使用的示例代码:

  public class videoa extends Activity {
  /** Called when the activity is first created. */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      this.setContentView(R.layout.main);

      VideoView videoView = (VideoView)this.findViewById(R.id.videoView);
      MediaController mc = new MediaController(this);
      videoView.setMediaController(mc);
      // (1) Web
      //videoView.setVideoURI(Uri.parse(
      //"http://www.bogotobogo.com/Video/sample.3gp"));
      //"http://www.bogotobogo.com/Video/sample.mp4"));
      //"http://www.bogotobogo.com/Video/sample.mov"));

      /* (2) SD card */
      //videoView.setVideoPath("/sdcard/sample.3gp");
      videoView.setVideoPath("/sdcard/robot.avi");
      //videoView.setVideoPath("/sdcard/sample.mov");
      // videoView.setVideoURI(Uri.parse(
        //"file:///sdcard/sample.mov"));

      videoView.requestFocus();
      videoView.start();
  }
}

我已手动启动并将目标设置为 -sdcard C:/android-sdk-windows/tools/sdcard.img

当我启动模拟器时,它显示视频无法显示

请帮帮我。

I am new to android. I am trying to play a video from sdcard.

this is the sample code I have used:

  public class videoa extends Activity {
  /** Called when the activity is first created. */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      this.setContentView(R.layout.main);

      VideoView videoView = (VideoView)this.findViewById(R.id.videoView);
      MediaController mc = new MediaController(this);
      videoView.setMediaController(mc);
      // (1) Web
      //videoView.setVideoURI(Uri.parse(
      //"http://www.bogotobogo.com/Video/sample.3gp"));
      //"http://www.bogotobogo.com/Video/sample.mp4"));
      //"http://www.bogotobogo.com/Video/sample.mov"));

      /* (2) SD card */
      //videoView.setVideoPath("/sdcard/sample.3gp");
      videoView.setVideoPath("/sdcard/robot.avi");
      //videoView.setVideoPath("/sdcard/sample.mov");
      // videoView.setVideoURI(Uri.parse(
        //"file:///sdcard/sample.mov"));

      videoView.requestFocus();
      videoView.start();
  }
}

I have launched manually And set the target as -sdcard C:/android-sdk-windows/tools/sdcard.img.

When i have launched the emulator it shows Video Cannot be Displayed.

Please help me out.

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

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

发布评论

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

评论(1

如果没有你 2024-09-26 02:04:36

你尝试交换 2 条线

 final String MEDIA_PATH = new String("/sdcard/robot.avi");


 VideoView videoView = (VideoView)this.findViewById(R.id.videoView);
 MediaController mc = new MediaController(this);

 videoView.setVideoPath(MEDIA_PATH);

 videoView.setMediaController(mc);

 videoView.requestFocus();
 videoView.start();

You try interchanging the 2 lines

 final String MEDIA_PATH = new String("/sdcard/robot.avi");


 VideoView videoView = (VideoView)this.findViewById(R.id.videoView);
 MediaController mc = new MediaController(this);

 videoView.setVideoPath(MEDIA_PATH);

 videoView.setMediaController(mc);

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