當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。