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
118:	return(mPlayer.getCurrentPosition()); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getCurrentPosition, getDuration
161:	return ((float)player.getCurrentPosition())/(float)player.getDuration(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getCurrentPosition
158:	return (int) (mPlayer.getCurrentPosition() / 1000); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getCurrentPosition, getDuration, isPlaying, pause, seekTo
280:	int skipOffset = 10000 + mediaPlayer.getCurrentPosition(); 
281:	int duration = mediaPlayer.getDuration(); 
-
288:	mediaPlayer.seekTo(skipOffset); 
-
294:	int skipOffset = mediaPlayer.getCurrentPosition() - 10000; 
-
301:	mediaPlayer.seekTo(skipOffset); 
-
306:	if (mediaPlayer.isPlaying()) { 
307:	mediaPlayer.pause(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getCurrentPosition
74:	return mp.getCurrentPosition(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getCurrentPosition, stop
37:	mSharedPreferences.edit().putInt("music_location", player.getCurrentPosition()).commit(); 
38:	player.stop(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getCurrentPosition, prepareAsync, reset, setDataSource, stop
289:	player.setDataSource(path); 
-
302:	player.prepareAsync(); 
-
352:	player.stop(); 
-
370:	player.reset(); 
-
412:	res = player.getCurrentPosition(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getCurrentPosition
41:	return mediaPlayer.getCurrentPosition(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getCurrentPosition, prepare, reset, seekTo, setDataSource
54:	int pos = mp.getCurrentPosition(); 
55:	mp.reset(); 
-
57:	mp.setDataSource(ctx, video); 
58:	mp.prepare(); 
59:	mp.start(); 
-
69:	mp.seekTo(pos); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getCurrentPosition
46:	return mediaPlayer.getCurrentPosition(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getCurrentPosition
47:	return mediaPlayer.getCurrentPosition(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getCurrentPosition, getDuration, prepare, release, seekTo
467:	MediaPlayer mp = new MediaPlayer(); 
-
469:	mp.setDataSource(filePath); 
470:	mp.prepare(); 
471:	duration = mp.getDuration(); 
472:	mp.seekTo(duration - 10000); 
473:	mp.start(); 
474:	currentPosition=mp.getCurrentPosition(); 
475:	mp.stop(); 
476:	mp.release(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getCurrentPosition
74:	return mp.getCurrentPosition(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getCurrentPosition, getDuration, setOnSeekCompleteListener, start
267:	+ mMediaPlayer.getCurrentPosition()); 
268:	mMediaPlayer.start(); 
269:	mMediaPlayer.setOnSeekCompleteListener(null); 
-
273:	if (endTimeMS < mMediaPlayer.getDuration()) { 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getCurrentPosition
140:	return player.getCurrentPosition() * 1000; 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getCurrentPosition, getDuration, isLooping, isPlaying
174:	result.put("duration", player.getDuration()); 
175:	result.put("position", player.getCurrentPosition()); 
176:	result.put("isplaying", player.isPlaying()); 
-
178:	result.put("looping", player.isLooping()); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getCurrentPosition
118:	return(mPlayer.getCurrentPosition()); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getCurrentPosition
23:	return mediaPlayer.getCurrentPosition(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getCurrentPosition
111:	return(mPlayer.getCurrentPosition()); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getCurrentPosition
118:	return(mPlayer.getCurrentPosition()); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getCurrentPosition
60:	int pos = player.getCurrentPosition(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getCurrentPosition
254:	return mediaPlayer.getCurrentPosition(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getCurrentPosition
63:	return mMediaPlayer.getCurrentPosition(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getCurrentPosition
104:	return player.getCurrentPosition(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getCurrentPosition
227:	return mMediaPlayer.getCurrentPosition(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getCurrentPosition
74:	return mp.getCurrentPosition(); 
Full Snippet Info
6
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

MediaPlayer class can be used to control playback of audio/video files and streams. An example on how to use the methods in this class can be found in VideoView.

Topics covered here are: State Diagram Valid and Invalid States Permissions Register informational and error callbacks Developer Guides For more information about how to use MediaPlayer, read the Media Playback developer guide. State Diagram Playback control of audio/video files and streams is managed as a state machine. The following diagram shows the life cycle and the states of a MediaPlayer object driven by the supported playback control operations. The ovals represent the states a MediaPlayer object may reside in. The arcs represent the playback control operations that drive the object state transition. There are two types of arcs. The arcs with a single arrow head represent synchronous method calls, while those with a double arrow head represent asynchronous method calls.From this state diagram, one can...
getCurrentPosition Method Overview
Gets the current playback position.
See Also
  • isLooping
    Checks whether the MediaPlayer is looping or non-looping.
  • isPlaying
    Checks whether the MediaPlayer is playing.
  • prepare
    Prepares the player for playback, synchronously.
  • prepareAsync
    Prepares the player for playback, asynchronously.
  • release
    Releases resources associated with this MediaPlayer object.
  • reset
    Resets the MediaPlayer to its uninitialized state.
  • seekTo
    Seeks to specified time position.
  • setDataSource
    Sets the data source (file-path or http/rtsp URL) to use.
  • setDisplay
    Sets the SurfaceHolder to use for displaying the video portion of the media.
  • setLooping
    Sets the player to be looping or non-looping.
  • setOnCompletionListener
    Register a callback to be invoked when the end of a media source has been reached during playback.
  • setOnErrorListener
    Register a callback to be invoked when an error has happened during an asynchronous operation.
  • setOnInfoListener
    Register a callback to be invoked when an info/warning is available.
  • setScreenOnWhilePlaying
    Control whether we should use the attached SurfaceHolder to keep the screen on while video playback is occurring.
  • setWakeMode
    Set the low-level power management behavior for this MediaPlayer.
  • start
    Starts or resumes playback.
  • stop
    Stops playback after playback has been stopped or paused.