gpt4 book ai didi

android - 在播放下一首歌曲时尝试在没有有效媒体播放器的情况下调用 getDuration

转载 作者:行者123 更新时间:2023-11-29 00:39:30 25 4
gpt4 key购买 nike

当我播放第一首歌曲时,它绝对没问题,但下次我收到标题文本的错误消息时,我在 mPlayer.prepare() 中收到错误,请提供帮助...

mPlayer.reset();
mPlayer.setOnCompletionListener(this);
mPlayer.setOnErrorListener(this); mPlayer.setDataSource(filePath);
mPlayer.prepare(); mPlayer.start(); isPlaying = true;
playPauseBtn.setEnabled(true); navigationbar.setEnabled(true);
totalMediaTime = mPlayer.getDuration() / 1000;
durationTextView.setText(Helper.getTimeFromSecods(totalMediaTime));
navigationbar.setMax(mPlayer.getDuration());

我收到错误代码 38...不知道是什么...

最佳答案

您正在尝试在准备完成之前获取 mediaPlayer.getDuration()。使用setOnPreparedListener()方法设置准备监听器,只有在准备完成后才调用getDuration()方法。

关于android - 在播放下一首歌曲时尝试在没有有效媒体播放器的情况下调用 getDuration,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10349339/

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