gpt4 book ai didi

Android 媒体 Controller 短时间显示

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:24:39 31 4
gpt4 key购买 nike

下面的这个 Activity 工作正常,但 mediaController 仅在我单击屏幕时显示。第二个问题是媒体 Controller 只显示 3 秒。我应该怎么做才能消除这个问题?

public class PlayingActivity extends Activity
{

private VideoView mVideoView;
private EditText mPath;
MediaController mediaController;

@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.playingactivity);
mPath = (EditText) findViewById(R.id.path);
mPath.setText(GlobalVariable.getstrEmail());
mVideoView = (VideoView) findViewById(R.id.surface_view);
Uri uri = Uri.parse("/sdcard/download/test.mp3");
mediaController = new MediaController(this);
mediaController.findFocus();
mediaController.setEnabled(true);
mediaController.show(0);
mediaController.setAnchorView(mVideoView);
mVideoView.setMediaController(mediaController);
mVideoView.setVideoURI(uri);
mVideoView.start();
}
}

最佳答案

mediaController.requestFocus();

将在视频开始时立即显示(无需点击)

mVideoView.setOnPreparedListener(new OnPreparedListener() {

@Override
public void onPrepared(MediaPlayer mp) {
mediaController.show(0);
}
});

将其保留在屏幕上。希望对你有帮助

关于Android 媒体 Controller 短时间显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6530250/

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