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

This code example shows how to use the following methods: prepareAsync
        mMediaPlayer.pause();
    } 
 
    @Override 
    public void prepareAsync() throws IllegalStateException { 
        mMediaPlayer.prepareAsync();
    } 
 
    @Override 
    public void release() { 
        mMediaPlayer.release();
    } 
 
    @Override 
    public void reset() { 
        mMediaPlayer.reset();
    } 
 
    @Override 
    public void seekTo(long msec) throws IllegalStateException {
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, prepareAsync, setAudioStreamType, setDataSource, setOnPreparedListener
	}	 
	 
	protected void startPlaying(String file) {
		if (isPlaying==false) {
			try { 
				mPlayer = new MediaPlayer();
				isPlaying=true;
				Log.d("Audio startPlaying", "audio: " + file);
				if (isStreaming(file))
				{ 
					Log.d("AudioStartPlaying", "Streaming");
					// Streaming prepare async 
					mPlayer.setDataSource(file);
					mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);  
					mPlayer.prepareAsync();
				} else { 
					Log.d("AudioStartPlaying", "File");
					// Not streaming prepare synchronous, abstract base directory 
					mPlayer.setDataSource("/sdcard/" + file);
					mPlayer.prepare();

6
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, prepareAsync
	public void onPrepared(MediaPlayer mp) {
		mp.start();
	} 
 
	public void play() { 
		if (!media_player.isPlaying()) {
			media_player.prepareAsync();
		} 
	} 
 
	public void pause() { 
		media_player.pause();
	} 
 
	public void stop() { 
		media_player.stop();
	} 
	 
	public void destroy() { 
		stop(); 
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: prepareAsync
        } 
    } 
 
    public void prepare() { 
        try { 
            player.prepareAsync();
        } catch (IllegalStateException e) {
            e.printStackTrace();
            Log.w(TAG, "err prepare: set data source did'n set");
        } 
    } 
 
    public boolean getPrepared() { 
        return isPrepared;
    } 
 
    public boolean isPlaying() { 
        return player.isPlaying();
    } 
 
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: prepareAsync, setAudioStreamType, setDataSource, setOnCompletionListener, setOnPreparedListener
    start(); 
  } 
 
  private void start() { 
    if( mediaPlayer != null ) mediaPlayer.release();
    mediaPlayer = new MediaPlayer();
    mediaPlayer.setAudioStreamType(AudioManager.STREAM_VOICE_CALL);
    mediaPlayer.setOnCompletionListener(this);
    mediaPlayer.setOnPreparedListener(this);
 
    String packageName = context.getPackageName();
    Uri dataUri = Uri.parse("android.resource://"+ packageName +"/"+ currentSoundID );
 
    try { 
      mediaPlayer.setDataSource(context, dataUri);
    } catch (IllegalArgumentException e) {
      // TODO Auto-generated catch block 
      e.printStackTrace();
      return; 
    } catch (SecurityException e) {

10
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: prepareAsync, setDataSource
            Log.i(TAG, "Playing track at URL=["+audioTrackURL+"]");
            mAudioTrackURL = audioTrackURL;
 
            if (mAudioSrvState == NOT_PLAYING) {
                try { 
                    mMediaPlayer.setDataSource(mAudioTrackURL);
                    mMediaPlayer.prepareAsync();
                } catch (IllegalArgumentException e) {
                    Log.e(TAG, "AudioTrackUrl seems to be incorrectly formatted",e);
                } catch (IllegalStateException e) {
                    Log.e(TAG, "MediaPlayer is in an illegal state",e);
                } catch (IOException e) {
                    Log.e(TAG, "MediaPlayer failed due to exception",e);
                } 
            } 
             
        } 
         
        public void stop() { 
            Log.i(TAG, "Call to stop streaming audio");
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, prepareAsync, setAudioStreamType, setDataSource, setOnPreparedListener
	}	 
	 
	protected void startPlaying(String file) {
		if (isPlaying==false) {
			try { 
				mPlayer = new MediaPlayer();
				isPlaying=true;
				Log.d("Audio startPlaying", "audio: " + file);
				if (isStreaming(file))
				{ 
					Log.d("AudioStartPlaying", "Streaming");
					// Streaming prepare async 
					mPlayer.setDataSource(file);
					mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);  
					mPlayer.prepareAsync();
				} else { 
					Log.d("AudioStartPlaying", "File");
					// Not streaming prepare synchronous, abstract base directory 
					mPlayer.setDataSource("/sdcard/" + file);
					mPlayer.prepare();

9
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: prepareAsync, setDataSource, setLooping, setOnPreparedListener
    final static String FILE = "file://";
 
    public Play(String uri, Context ctx) throws Exception {
        super(uri);
        _uri = uri;
        _mp = new MediaPlayer();
        if (uri.startsWith(FILE)) {
            _mp.setDataSource(uri);
            _mp.prepare();
            _prepared = true;
        } else { 
            _mp.setDataSource(uri);
            _mp.setOnPreparedListener(this);
            _mp.prepareAsync();
        } 
        _mp.setLooping(true);
        //_mp.setAudioStreamType(AudioManager.MODE_RINGTONE); 
    } 
 
    public void stop() { 
        if (_mp != null) {
Full Snippet Info
8
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: 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
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, prepareAsync, stop
            mMediaPlayer.pause();
        } 
    } 
 
    public void onStopButton(View view) {
        if (!mMediaPlayer.isPlaying()) {
            return; 
        } 
        mMediaPlayer.stop();
        isPrepared = false;
        // もう一度再生されるために準備しておく 
        try { 
            // prepareAsync()ではなくてprepare()を呼ぶと 
            // stopping状態にprepare()が要求されて 
            // java.lang.IllegalStateExceptionが発生する 
            mMediaPlayer.prepareAsync();
        } catch (IllegalStateException e) {
            e.printStackTrace();
        } 
    } 
} 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related MediaPlayer prepareAsync Questions & Answers:

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