Closed davidgassner closed 8 years ago
The onCompletion method isn't being called when an audio cue is finished playing. I've tried it with a couple of different audio files and seen the same thing. The same code and files do work with a standard MediaPlayer. My code:
mPlayerFactory = new OpenSLMediaPlayerFactory(mContext); mMediaPlayer = mPlayerFactory.createMediaPlayer(); mMediaPlayer.setOnPreparedListener(new IBasicMediaPlayer.OnPreparedListener() { @Override public void onPrepared(IBasicMediaPlayer mp) { mPrepared = true; mService.onPrepared(mCue.getCueId()); startCue(mMediaPlayer); } }); mMediaPlayer.setOnCompletionListener(new IBasicMediaPlayer.OnCompletionListener() { @Override public void onCompletion(IBasicMediaPlayer mp) { Log.i(TAG, "onCompletion"); stopAndRemove(); } }); FileInputStream stream = null; try { stream = new FileInputStream(fullFileName); mMediaPlayer.setDataSource(stream.getFD()); mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mMediaPlayer.setVolume(this.mVolume, this.mVolume); mMediaPlayer.prepare(); } catch (IOException e) { e.printStackTrace(); return false; } finally { if (stream != null) { try { stream.close(); } catch (IOException ignore) { } } }
Any advice is appreciated, thanks!
Disregard this, I changed the call to setDataSource() to use a Uri and it now works.
The onCompletion method isn't being called when an audio cue is finished playing. I've tried it with a couple of different audio files and seen the same thing. The same code and files do work with a standard MediaPlayer. My code:
Any advice is appreciated, thanks!