Best code examples for MediaPlayer getCurrentPosition method (android.media.MediaPlayer.getCurrentPosition)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for MediaPlayer getCurrentPosition method.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

MediaPlayer getCurrentPosition examples from Open Source projects
This code example shows how to use the following methods: getCurrentPosition
    }  
	 
	protected long getCurrentPosition() { 
		if (isPlaying) 
		{ 
			return(mPlayer.getCurrentPosition());
		} else { return(-1); } 
	} 
	 
	private boolean isStreaming(String file) 
	{ 
		if (file.contains("http://")) {
			return true; 
		} else { 
			return false; 
		} 
	} 
	 
	protected long getDuration(String file) {
		long duration = -2;
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getCurrentPosition, getDuration
		if(stream && player!=null) player.seekTo(ms); // 0 = start, 1 = end;
	} 
	 
	float getPosition(){ 
		if(stream && player!=null)
			return ((float)player.getCurrentPosition())/(float)player.getDuration();
		else 
			return 0; 
	} 
	 
	int getPositionMS(){ 
		if(stream && player!=null)
			return player.getCurrentPosition();
		else 
			return 0; 
	} 
	 
	boolean getIsPlaying(){ 
		if(stream)
			return player!=null && player.isPlaying();
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getCurrentPosition
    public int progress() { 
        if (mState == RECORDING_STATE) {
            return (int) ((System.currentTimeMillis() - mSampleStart) / 1000);
        } else if (mState == PLAYING_STATE || mState == PLAYING_PAUSED_STATE) {
            if (mPlayer != null) {
                return (int) (mPlayer.getCurrentPosition() / 1000);
            } 
        } 
 
        return 0; 
    } 
 
    public float playProgress() { 
        if (mPlayer != null) {
            return ((float) mPlayer.getCurrentPosition()) / mPlayer.getDuration();
        } 
        return 0.0f; 
    } 
 
    public int sampleLength() { 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getCurrentPosition, getDuration, isPlaying, pause, seekTo
			return true; 
		} 
 
		if ((keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD || keyCode == KeyEvent.KEYCODE_MEDIA_NEXT)
				&& isMediaPlayerStateValid()) { 
			int skipOffset = 10000 + mediaPlayer.getCurrentPosition();
			int duration = mediaPlayer.getDuration();
			if (skipOffset > duration) {
				skipOffset = duration - 1;
			} 
			if (!mediaController.isShowing()) {
				mediaController.show(CONTROLLER_DELAY);
			} 
			mediaPlayer.seekTo(skipOffset);
			return true; 
		} 
 
		if ((keyCode == KeyEvent.KEYCODE_MEDIA_REWIND || keyCode == KeyEvent.KEYCODE_MEDIA_PREVIOUS)
				&& isMediaPlayerStateValid()) { 
			int skipOffset = mediaPlayer.getCurrentPosition() - 10000;

6
CodeRank
This code example shows how to use the following methods: getCurrentPosition
		return -1; 
	} 
 
	public int getCurrentPosition() { 
		if (mp != null)
			return mp.getCurrentPosition();
		return -1; 
	} 
	 
	public boolean isPlaying() { 
		if (mp != null)
			return mp.isPlaying();
		return false; 
	} 
	 
	public void pause() { 
		if (mp != null)
			mp.pause();
	} 
	 
Full Snippet Info
7
CodeRank
Related MediaPlayer getCurrentPosition Questions & Answers:
Other MediaPlayer getCurrentPosition Examples
115:					// get current song position
116:					int currentPosition = mp.getCurrentPosition();
117:					// check if seekForward time is lesser than song duration
118:					if(currentPosition + seekForwardTime <= mp.getDuration()){
119:						// forward song

Read More

getCurrentPosition Method Overview
Gets the current playback position.
See Code Examples for other Android MediaPlayer Methods: