MediaPlayer prepare - 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 prepare method.

This code example shows how to use the following methods: prepare, seekTo, start, stop
		} 
	} 
	 
	public void rewindBackgroundMusic(){		 
		if (mBackgroundMediaPlayer != null){
			mBackgroundMediaPlayer.stop();			
			 
			try { 
				mBackgroundMediaPlayer.prepare();
				mBackgroundMediaPlayer.seekTo(0);
				mBackgroundMediaPlayer.start();
				 
				this.mIsPaused = false;
			} catch (Exception e){
				Log.e(TAG, "rewindBackgroundMusic: error state");
			}			 
		} 
	} 
	 
	public boolean isBackgroundMusicPlaying(){ 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: isPlaying, prepare, setAudioStreamType, setDataSource, start
    public boolean isActive() { 
        return false; 
    } 
 
    public boolean isRunning() { 
        return player != null && player.isPlaying();
    } 
 
    public void start() { 
        if (!isOpen()) { 
            throw new IllegalStateException("Clip must be open");
        } 
         
        if (stream == null) {
            throw new IllegalStateException("Need an AudioInputStream to play");
        } 
 
        if (!isRunning()) { 
            /* 
             * This is ugly, but there is no way around it: The javax.sound API 

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: isPlaying, prepare, seekTo, stop
	 
	public static void stopMusic() 
	{ 
		if(mPlayer != null)
		{ 
			if(mPlayer.isPlaying())
			{ 
				mPlayer.stop();
				try 
				{ 
					mPlayer.prepare();
					mPlayer.seekTo(0);
				} 
				catch (IOException e)
				{ 
					// do nothing here FIXME 
				} 
			} 
		} 
	} 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getDuration, prepare, release, setDataSource
 
	protected long getDuration(String file) {
		long duration = -2;
		if (!isPlaying & !isStreaming(file)) {
			try { 
				mPlayer = new MediaPlayer();
				mPlayer.setDataSource("/sdcard/" + file);
				mPlayer.prepare();
				duration = mPlayer.getDuration();
				mPlayer.release();
			} catch (Exception e) { e.printStackTrace(); return(-3); }
		} else 
		if (isPlaying & !isStreaming(file)) {
			duration = mPlayer.getDuration();
		} else  
		if (isPlaying & isStreaming(file)) {
			try { 
				duration = mPlayer.getDuration();
			} catch (Exception e) { e.printStackTrace(); return(-4); }
		}else { return -1; } 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: prepare, setAudioStreamType, setDataSource
	private int state;
	 
	public PGPolyphonicVoice( AssetFileDescriptor afd )  throws IOException
	{ 
		state = INVALID;
		mp = new MediaPlayer();
		mp.setDataSource( afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
		mp.setAudioStreamType(AudioManager.STREAM_MUSIC);  
		mp.prepare();
	} 
	 
	public void play() throws IOException 
	{ 
		invokePlay( false ); 
	} 
	 
	private void invokePlay( Boolean loop )
	{ 
		Boolean playing = ( mp.isLooping() || mp.isPlaying() );
		if ( playing )
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related MediaPlayer prepare Questions & Answers:

Other MediaPlayer prepare Examples

237:			});
238:	
239:			/**
240:			 * Button Click event for Play list click event
241:			 * Launches list activity which displays list of songs

Read More

prepare Method Overview
Prepares the player for playback, synchronously.
See Code Examples for other Android MediaPlayer Methods: