1

我制作了一个流程序来播放广告+音频+广告。我播放第一个广告很好,然后我切换到很好的音频,然后我无法播放最后一个广告,我得到错误(38,0)。我检查了我是否设置了数据源,onPrepareListener,并且我尝试了到目前为止我能找到的所有东西,但在 android 4.1.1 上仍然出现此错误我在我的方法 MPStarting 后出现错误,我什至没有达到仅用于最终广告的 onPrepared 方法.如果有任何信息你需要更多请告诉我谢谢。这是相关的代码部分

MPStarting(Track)
{    try
{   
    if (_playlist !=null && _playlist.GetCurrent() != null)
    {                   
        Episode ep = (Episode) _playlist.GetCurrent();
        _player = new MediaPlayer();
        AdsInfo startAd = ep.getAdWithType(PlayTime.start_ad);
        AdsInfo endAd = ep.getAdWithType(PlayTime.end_ad);
        if(currAudio == null && startAd != null)
            currAudio = startAd;
        else if(currAudio == startAd )
            currAudio = ep;
        else if (currAudio instanceof Episode && endAd != null)
            currAudio = ep.getAdWithType(PlayTime.end_ad);
    }
    if(_player != null)
    {
        _player.setDataSource(dataSource);
        _player.setOnPreparedListener(this);
        _player.setOnCompletionListener(this);
        _player.setOnBufferingUpdateListener(this);
        _player.setOnSeekCompleteListener(this);
        _player.setOnErrorListener(this);           
        _player.prepareAsync();
    }

    catch (Exception e) 
    {
        Log.i("mpcPlayer","MPStarting "+ e.getLocalizedMessage());
    } 

}
}
@Override
public void onCompletion(MediaPlayer mp) 
{
//here i check on current playing
//i always stop player if it is playing ,reset,release and make player = null
// then i call MPStarting and i send the current audio then return
}
4

1 回答 1

0

我想我发现了我的问题,我有时会调用 getCurrentPosition() 似乎播放器当时还没有准备好。我猜这个错误是关于有时调用一个方法,而播放器没有处于正确的状态。

于 2015-06-08T09:29:08.640 回答