Java 不在Android 2.3上播放MP4视频

Java 不在Android 2.3上播放MP4视频,java,android,video-streaming,android-videoview,avd,Java,Android,Video Streaming,Android Videoview,Avd,我有一个视频视图,我想在其中显示一个来自URL的MP4视频。我在andoird4.0.2模拟器上试过,效果很好。然而,在姜饼硬件上试用时,它崩溃了。我也在姜饼模拟器上试过,我想我的设备可能有问题,但还是没有进展。当我点击播放按钮时,logcat会一次又一次地重复这些操作 04-11 23:49:27.438:V/VideoViewDemo(413):路径:http://173.193.24.66/~kanz/video/mp4/9.mp4 04-11 23:49:28.796:D/MediaPl

我有一个视频视图,我想在其中显示一个来自URL的MP4视频。我在andoird4.0.2模拟器上试过,效果很好。然而,在姜饼硬件上试用时,它崩溃了。我也在姜饼模拟器上试过,我想我的设备可能有问题,但还是没有进展。当我点击播放按钮时,logcat会一次又一次地重复这些操作

04-11 23:49:27.438:V/VideoViewDemo(413):路径:http://173.193.24.66/~kanz/video/mp4/9.mp4
04-11 23:49:28.796:D/MediaPlayer(413):无法在客户端打开文件,正在尝试服务器端
04-11 23:49:38.207:D/MediaPlayer(413):获取元数据
04-11 23:49:39.343:W/MediaPlayer(413):信息/警告(701,0)
04-11 23:49:39.346:I/MediaPlayer(413):信息(701,0)
04-11 23:49:45.556:W/MediaPlayer(413):信息/警告(702,0)
04-11 23:49:45.556:I/MediaPlayer(413):信息(702,0)
04-11 23:51:11.467:W/MediaPlayer(413):信息/警告(701,0)
04-11 23:51:11.467:I/MediaPlayer(413):信息(701,0)
04-11 23:51:22.096:W/MediaPlayer(413):信息/警告(702,0)
04-11 23:51:22.096:I/MediaPlayer(413):信息(702,0)
04-11 23:51:25.636:W/MediaPlayer(413):信息/警告(701,0)
04-11 23:51:25.636:I/MediaPlayer(413):信息(701,0)
04-11 23:51:37.127:W/MediaPlayer(413):信息/警告(702,0)
04-11 23:51:37.127:I/MediaPlayer(413):信息(702,0)
04-11 23:51:41.717:W/MediaPlayer(413):信息/警告(701,0)
04-11 23:51:41.717:I/MediaPlayer(413):信息(701,0)
04-11 23:51:54.086:W/MediaPlayer(413):信息/警告(702,0)
04-11 23:51:54.097:I/MediaPlayer(413):信息(702,0)

它没有显示任何错误,这样我就可以知道到底是哪一行导致了问题。以下是播放按钮的代码:

try {
        final String path = mPath.getText().toString();
        Log.v(TAG, "path: " + path);
        if (path == null || path.length() == 0) {
            Toast.makeText(MainActivity.this, "File URL/path is empty",
                    Toast.LENGTH_LONG).show();

        } else {
            // If the path has not changed, just start the media player
            if (path.equals(current) && mVideoView != null) {


                mVideoView.setVideoURI(Uri.parse("http://173.193.24.66/~kanz/video/mp4/9.mp4"));

                mVideoView.requestFocus();

                mVideoView.start();
                return;
            }
             current = path;

            mVideoView.setVideoURI(Uri.parse(getDataSource(path)));


            mVideoView.requestFocus();
            mVideoView.start();


        }
    } catch (Exception e) {
        Log.e(TAG, "error: " + e.getMessage(), e);
        if (mVideoView != null) {
            mVideoView.stopPlayback();
        }
    }
}

任何帮助都将不胜感激。谢谢。

您可能想试试这段代码

String videoSource = "http://173.193.24.66/~kanz/video/mp4/9.mp4";

myVideoView.setMediaController(new MediaController(this));
myVideoView.setVideoPath(videoSource);
myVideoView.requestFocus();
myVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
  public void onPrepared(MediaPlayer mp) {
    myVideoView.start();
  }
});

您是在模拟器上还是在真实手机上进行尝试?