gpt4 book ai didi

android - videoview的onpreparedlistener()出错

转载 作者:行者123 更新时间:2023-11-29 20:14:00 27 4
gpt4 key购买 nike

我想在 videoview 中加载视频之前有一个进度条。但是我收到以下错误。我还添加了所有必要的导入。 enter image description here enter image description here

我在 ANDROID 中使用 AIDE

这是我的代码

public class MainActivity extends Activity{
ProgressBar progressBar = null;

VideoView videoView = null;

String videoUrl = "http://www.androidbegin.com/tutorial/AndroidCommercial.3gp";

Context context = null;

@Override
public void onCreate(Bundle iclic) {
super.onCreate(iclic);

context = null;

requestWindowFeature(Window.FEATURE_NO_TITLE);

setContentView(R.layout.main);

videoView = (VideoView) findViewById(R.id.videoview);
progressBar = (ProgressBar) findViewById(R.id.progressbar);

Uri videoUri = Uri.parse(videoUrl);

videoView.setVideoURI(videoUri);
videoView.start();

progressBar.setVisibility(View.VISIBLE);

videoView.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
// TODO Auto-generated method stub
mp.start();
mp.setOnVideoSizeChangedListener(new OnVideoSizeChangedListener() {
@Override
public void onVideoSizeChanged(MediaPlayer mp, int arg1,
int arg2) {
// TODO Auto-generated method stub
progressBar.setVisibility(View.GONE);
mp.start();
}
});

}
});

}

}

没明白是什么问题!

最佳答案

试试这个,完美

new OnPreparedListener() 替换为 new MediaPlayer.OnPreparedListener() 并将 new OnVideoSizeChangedListener() 替换为 new MediaPlayer.OnVideoSizeChangedListener( )

关于android - videoview的onpreparedlistener()出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34331537/

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