MediaPlayer reset - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for MediaPlayer reset method.

This code example shows how to use the following methods: isPlaying, prepare, reset, setDataSource, start
		mediaPlayer = new MediaPlayer();
		isPaused  = false;
	} 
		 
	public void play() { 
    	if (!mediaPlayer.isPlaying() && currentTrack != null) {
    		try { 
    			if (!isPaused) {
    				mediaPlayer.reset();
        			mediaPlayer.setDataSource(currentTrack);
        			mediaPlayer.prepare();
        			isPaused = false;
    			} 
    			mediaPlayer.start();    			
			} catch (Exception e) {
				//ignore 
			}    		 
    	} 
    } 
     
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: pause, release, reset
     * Processes a request to pause the current playback  
     */ 
    protected void processPauseRequest() { 
        if (mState == State.PLAYING) {
            mState = State.PAUSED;
            mPlayer.pause();
            releaseResources(false); // retain media player in pause 
            // TODO polite audio focus, instead of keep it owned; or not? 
        } 
    } 
     
     
    /** 
     * Processes a request to stop the playback. 
     *  
     * @param   force       When 'true', the playback is stopped no matter the value of mState 
     */ 
    protected void processStopRequest(boolean force) {
        if (mState != State.PREPARING || force) {
            mState = State.STOPPED;

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: isPlaying, reset, stop
         
        public void stop() { 
            Log.i(TAG, "Call to stop streaming audio");
 
            if (mMediaPlayer != null) {
                if (mMediaPlayer.isPlaying()) {
                    Log.i(TAG, "media player was playing and is now Stopping");
                    mMediaPlayer.stop();
                    mMediaPlayer.reset();
                    mAudioSrvState = NOT_PLAYING;
                } 
            } 
        } 
         
        public String getFileName() {
            return null; 
        } 
 
        public long getPosition() { 
            return 0; 
Full Snippet Info
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: isPlaying, release, reset, stop
	public static void releasePlayer() 
	{ 
		if(qiraatPlayer != null)
		{ 
			currentAyaPos = 0;
			if(qiraatPlayer.isPlaying())
			{ 
				qiraatPlayer.stop();
			} 
			qiraatPlayer.reset();
			qiraatPlayer.release();		
			//Need to set this to null manually. After calling release(), cannot call any other method on the mediaplayer object. 
			qiraatPlayer = null;
		} 
	} 
	public static boolean isPlaying() { 
		// TODO Auto-generated method stub 
		if(qiraatPlayer != null)
		{ 
			return qiraatPlayer.isPlaying();
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: release, reset, stop
		player = new MediaPlayer();
	} 
 
	@Override 
	public void onDestroy() { 
		player.stop();
		player.reset();
		player.release();
		Toast.makeText(this, "Stream Stopped", Toast.LENGTH_LONG).show();
		Log.d(TAG, "onDestroy");
	} 
	 
	@Override 
	public void onStart(Intent intent, int startid) {
		Log.d(TAG, "onStart");
		onBind(intent);
	} 
} 
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: isPlaying, prepare, reset, setDataSource, start
    @Override 
    public void startPlaying() throws IllegalArgumentException, 
	    IllegalStateException, IOException { 
 
	if (mPlayer != null) {
	    if (mPlayer.isPlaying())
		mPlayer.stop();
	    mPlayer.reset();
	} else { 
	    mPlayer = new MediaPlayer();
	    mPlayer.setOnCompletionListener(this);
	} 
	mPlayer.setDataSource(mFile);
	mPlayer.prepare();
	mPlayer.start();
    } 
 
    @Override 
    public boolean isPlaying() { 
	return mPlayer != null && mPlayer.isPlaying();
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: prepareAsync, release, reset, setDataSource
    } 
 
    public static boolean prepareAsyncReset(String filePath){    
        //preparesAsync  
        try{ 
            MediaPlayer mp = new MediaPlayer();
            mp.setDataSource(filePath);
            mp.prepareAsync();
            mp.reset();
            mp.release();
        }catch (Exception e){
            Log.v(TAG,e.getMessage());
            return false; 
        } 
        return true; 
    } 
 
 
    public static boolean isLooping(String filePath) {        
        MediaPlayer mp = null;
Full Snippet Info
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: pause, release, reset
        } 
 
        if (mState == State.Playing) {
            // Pause media player and cancel the 'foreground service' state. 
            mState = State.Paused;
            mPlayer.pause();
            relaxResources(false); // while paused, we always retain the MediaPlayer 
            // do not give up audio focus 
        } 
 
        // Tell any remote controls that our playback state is 'paused'. 
        if (mRemoteControlClientCompat != null) {
            mRemoteControlClientCompat
                    .setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
        } 
    } 
 
    void processRewindRequest() { 
        if (mState == State.Playing || mState == State.Paused)
            mPlayer.seekTo(0);

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: prepare, reset, setDataSource, start, stop
		this.mp3 = mp3;
 
		try { 
			switch (status) {
				case INICIADO:
					player.stop();
				case PARADO:
					player.reset();
				case NOVO:
					player.setDataSource(mp3);
					player.prepare();
				case PAUSADO:
					player.start();
					break; 
			} 
 
			status = INICIADO;
		} catch (Exception e) {
			Log.e(CATEGORIA,e.getMessage(),e);
		} 
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getCurrentPosition, prepareAsync, reset, setDataSource, stop
    public void setDataSource(String path) {
        Log.w(TAG, "Set data source: " + path);
        setDataSource = true;
        isPrepared = false;
        try { 
            player.setDataSource(path);
            Log.w(TAG, "Set data source: " + path);
        } catch (IOException ex) {
            Log.w(TAG, "error set data source", ex);
        } catch (IllegalArgumentException ex) {
            Log.w(TAG, "error set data source", ex);
        } catch (IllegalStateException ex) {
            Log.w(TAG, "error set data source", ex);
        } 
    } 
 
    public void prepare() { 
        try { 
            player.prepareAsync();
        } catch (IllegalStateException e) {

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related MediaPlayer reset Questions & Answers:

Other MediaPlayer reset Examples

235:					}
236:				}
237:			});
238:	
239:			/**

Read More

reset Method Overview
Resets the MediaPlayer to its uninitialized state.
See Code Examples for other Android MediaPlayer Methods: