我有一个媒体播放器,我正在尝试播放mp4视频,但我只想要音频。所以我正在使用媒体播放器。在那里我想能够使用寻求但由于某种原因,寻求是非常不准确的。如果我输入一个向前跳过5秒的功能。它会从5秒向后跳到15秒。怎么可能这是不准确的。有没有办法让搜索更准确?其他一些视频格式不会发生这种情况。
player = new MediaPlayer();
player.setWakeMode(getApplicationContext(),
PowerManager.PARTIAL_WAKE_LOCK);
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
player.setDataSource(fileInputStream.getFD());
player.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
player.setOnCompletionListener(listener);
playMusic();
}
});
player.prepareAsync();
public void playMusic() {
try {
if (player != null && !player.isPlaying()) {
//player.seekTo(1); seeks to begining
//player.seekTo(311); skips to 15 seconds
player.setOnSeekCompleteListener(new MediaPlayer.OnSeekCompleteListener() {
@Override
public void onSeekComplete(MediaPlayer mediaPlayer) {
player.start();
}
});