Code example for AssetFileDescriptor

Methods: close, getFileDescriptor, getLength, getStartOffset

0
    } 
    private void setDataSourceFromResource(Resources resources,
            MediaPlayer player, int res) throws java.io.IOException {
        AssetFileDescriptor afd = resources.openRawResourceFd(res);
        if (afd != null) {
            player.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(),
                    afd.getLength());
            afd.close();
        } 
    } 
 
    // Do the common stuff when starting the alarm. 
    private void startAlarm(MediaPlayer player, boolean looping)
            throws java.io.IOException, IllegalArgumentException, 
                   IllegalStateException { 
        player.setAudioStreamType(AudioManager.STREAM_ALARM);
        player.setLooping(looping);
        player.prepare();
        player.start();
    } 
    /**