当前位置: 首页>>代码示例>>Java>>正文


Java MediaPlayer.getCurrentPosition方法代码示例

本文整理汇总了Java中android.media.MediaPlayer.getCurrentPosition方法的典型用法代码示例。如果您正苦于以下问题:Java MediaPlayer.getCurrentPosition方法的具体用法?Java MediaPlayer.getCurrentPosition怎么用?Java MediaPlayer.getCurrentPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.media.MediaPlayer的用法示例。


在下文中一共展示了MediaPlayer.getCurrentPosition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resume

import android.media.MediaPlayer; //导入方法依赖的package包/类
/**
 * resume playing
 *
 * @return
 */
public synchronized UDAudio resume() {
    final MediaPlayer player = getMediaPlayer();
    if (player != null && player.isPlaying() == false) {
        try {
            if (player.getCurrentPosition() > 0) {
                player.start();
            } else {
                play(mUriOrName, mLoopTimes);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return this;
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:21,代码来源:UDAudio.java

示例2: onSeekComplete

import android.media.MediaPlayer; //导入方法依赖的package包/类
@Override
public void onSeekComplete(MediaPlayer mp) {
    Logger.d(TAG, "onSeekComplete from MediaPlayer:", mp.getCurrentPosition());
    mCurrentPosition = mp.getCurrentPosition();
    if (mState == PlaybackStateCompat.STATE_BUFFERING) {
        registerAudioNoisyReceiver();
        mMediaPlayer.start();
        mState = PlaybackStateCompat.STATE_PLAYING;
    }
    if (mCallback != null) {
        mCallback.onPlaybackStatusChanged(mState);
    }
}
 
开发者ID:dibakarece,项目名称:DMAudioStreamer,代码行数:14,代码来源:AudioPlaybackListener.java

示例3: onPrepared

import android.media.MediaPlayer; //导入方法依赖的package包/类
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
    mediaPlayer.start();
    isPlaying = true;
    this.duration = mediaPlayer.getDuration();
    this.currentTime = mediaPlayer.getCurrentPosition();
    updateTimeAudio();

    if (jcPlayerServiceListeners != null) {
        for (JcPlayerView.JcPlayerViewServiceListener jcPlayerServiceListener : jcPlayerServiceListeners) {
            jcPlayerServiceListener.updateTitle(currentJcAudio.getTitle());
            jcPlayerServiceListener.onPreparedAudio(currentJcAudio.getTitle(), mediaPlayer.getDuration());
        }
    }

    if (notificationListener != null) {
        notificationListener.updateTitle(currentJcAudio.getTitle());
        notificationListener.onPreparedAudio(currentJcAudio.getTitle(), mediaPlayer.getDuration());
    }

    if (jcPlayerStatusListeners != null) {
        for (JcPlayerView.JcPlayerViewStatusListener jcPlayerViewStatusListener : jcPlayerStatusListeners) {
            jcStatus.setJcAudio(currentJcAudio);
            jcStatus.setPlayState(JcStatus.PlayState.PLAY);
            jcStatus.setDuration(duration);
            jcStatus.setCurrentPosition(currentTime);
            jcPlayerViewStatusListener.onPreparedAudioStatus(jcStatus);
        }
    }
}
 
开发者ID:yusufkocak1,项目名称:TMP-Music_player,代码行数:31,代码来源:JcPlayerService.java

示例4: onSeekComplete

import android.media.MediaPlayer; //导入方法依赖的package包/类
@Override
public void onSeekComplete(MediaPlayer mediaPlayer) {
    Log.i(TAG, "onSeekComplete, current position: " + mCurrentPosition);
    mCurrentPosition = mediaPlayer.getCurrentPosition();
    if (mPlaybackState == PlaybackStateCompat.STATE_BUFFERING) {
        mPlayer.start();
        mPlaybackState = PlaybackStateCompat.STATE_PLAYING;
    }
    if (mCallback != null) {
        mCallback.onPlayStateChanged(mPlaybackState);
    }
}
 
开发者ID:Jaysaw,项目名称:NovaMusicPlayer,代码行数:13,代码来源:LocalPlayback.java

示例5: onSeekComplete

import android.media.MediaPlayer; //导入方法依赖的package包/类
/**
 * Called when MediaPlayer has completed a seek
 *
 * @see OnSeekCompleteListener
 */
@Override
public void onSeekComplete(MediaPlayer mp) {
    mCurrentPosition = mp.getCurrentPosition();
    if (mState == PlaybackStateCompat.STATE_BUFFERING) {
        registerAudioNoisyReceiver();
        mMediaPlayer.start();
        mState = PlaybackStateCompat.STATE_PLAYING;
    }
    if (mCallback != null) {
        mCallback.onPlaybackStateChanged(mState);
    }
}
 
开发者ID:AllThatSeries,项目名称:react-native-streaming-audio-player,代码行数:18,代码来源:Playback.java

示例6: voicePlay

import android.media.MediaPlayer; //导入方法依赖的package包/类
public static void voicePlay(final MediaPlayer player, String path, final SeekBar seekBar, final Chronometer chronometer) {
    if (player != null) {
        setChronometer(chronometer, Constant.CHRONOMETER_START);
        if (!isPlaying) {
            player.setAudioStreamType(AudioManager.STREAM_MUSIC);
            try {
                player.setDataSource(path);
                player.prepare();
            } catch (IOException e) {
                e.printStackTrace();
            }
            isPlaying = true;
        }


        player.start();

        //设置Bar的最大值
        int max = player.getDuration();
        seekBar.setMax(max);
        //定时器更新进度条
        final Timer timer = new Timer();
        TimerTask timeTask = new TimerTask() {
            @Override
            public void run() {
                // TODO Auto-generated method stub
                int a = player.getCurrentPosition();
                seekBar.setProgress(player.getCurrentPosition());
            }
        };
        timer.schedule(timeTask, 0, 500);

    /*player.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

        public void onPrepared(MediaPlayer mp) {
            // TODO Auto-generated method stub
            player.start();
            seekBar.setMax(player.getDuration());
            seekBar.setEnabled(true);
        }
    });*/

        //音频播放完之后重新设置显示
        player.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mp) {
                // TODO Auto-generated method stub
                seekBar.setProgress(0);
                setChronometer(chronometer, Constant.CHRONOMETER_RESET);
                timer.cancel();
            }
        });
    }
}
 
开发者ID:lpy19930103,项目名称:MinimalismJotter,代码行数:55,代码来源:RecoderManager.java


注:本文中的android.media.MediaPlayer.getCurrentPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。