3

当我使用以下代码mp4在android中播放视频文件时

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //setContentView(R.layout.activity_intro);

//  vvIntro = (VideoView) findViewById(R.id.vvIntro);
    VideoView vvIntro = new VideoView(this);
    Uri video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.intro); 

    vvIntro.setVideoURI(video);
    setContentView(vvIntro);
    vvIntro.start();
}

我收到以下错误?

04-29 23:04:38.740: E/MediaPlayer(25435): Unable to to create media player
04-29 23:04:38.748: D/MediaPlayer(25435): Couldn't open file on client side, trying server side
04-29 23:04:38.748: E/MediaPlayer(25435): error (1, -2147483648)
04-29 23:04:38.818: E/MediaPlayer(25435): Error (1,-2147483648)
04-29 23:04:38.818: D/VideoView(25435): Error: 1,-2147483648

这是什么意思 ?

4

1 回答 1

0
// Try this code   

int raw_id = getResources().getIdentifier(Filename_without_extension, "raw",getPackageName());

String PATH="android.resource://"+getPackageName()+"/"+raw_id;
mVideoView.setVideoURI(Uri.parse(PATH));
mVideoView.setMediaController(new MediaController(Classname.this));
mVideoView.requestFocus();
mVideoView.start();
于 2014-07-23T12:35:31.180 回答