Code example for ByteBuffer

Methods: get, limit, position

0
	 * @return true if the audioData is of type "audio", false if not. 
	 */ 
	final boolean checkIfMimeAudioType(ByteBuffer audioData, int offset)
	{ 
		// No point in checking audio type unless we have at least five bytes. 
		if (audioData.limit() < 5)
		{ 
			//Log.e("MoSyncAudio.checkIfMimeAudioType", 
			//	"Resource was smaller than 5 bytes"); 
			return false; 
		} 
 
		// Save current position on the byte buffer. 
		int savedPosition = audioData.position();
 
		// Read first five bytes of audio data. 
		byte header[] = new byte[5];
		audioData.position(offset);
		audioData.get(header);
 
		// Restore buffer position. 
		audioData.position(savedPosition);
 
		// Check mime type. 
		return checkIfMimeAudioType(header);
	}