gpt4 book ai didi

android - 在android中的VideoView中播放视频时出错

转载 作者:太空狗 更新时间:2023-10-29 15:11:05 26 4
gpt4 key购买 nike

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

@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

这是什么意思?

最佳答案

// 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();

关于android - 在android中的VideoView中播放视频时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16287302/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com