Android AssetFileDescriptor - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android AssetFileDescriptor class.

This code example shows how to use the following methods: getFileDescriptor, getLength, getStartOffset
	 
	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
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: getFileDescriptor, getLength, getStartOffset, sleep
    //Load midi file from resources 
    public static boolean resourcesPlayback(AssetFileDescriptor afd, int expectedDuration){
        int duration = 0;
        try{ 
            MediaPlayer mp = new MediaPlayer();
            mp.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(), afd.getLength());
            mp.prepare();
            mp.start();
            duration = mp.getDuration();
            Thread.sleep(5000);
            mp.release();
        }catch (Exception e){
            Log.v(TAG,e.getMessage());
        } 
        if (duration > expectedDuration)
            return true; 
        else 
            return false; 
    } 
 
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: close, getFileDescriptor, getLength, getStartOffset
	      @Override 
	      public void onCompletion(MediaPlayer player) {
	        player.release();
	      } 
	    }); 
	    player.setDataSource(file.getFileDescriptor(), file.getStartOffset(), file.getLength());
	    file.close();
	    player.setVolume(0.2f, 0.2f);
	    player.prepare();
	    player.start();
	} 
} 
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: getFileDescriptor, getLength, getStartOffset
	 
	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
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: createInputStream, getLength

Related Android AssetFileDescriptor Questions & Answers:

See Code Examples for Android AssetFileDescriptor Methods: