FileDocCategorySizeDatePackage
VariableSpeedNative.javaAPI DocAndroid 5.1 API3534Thu Mar 12 22:22:48 GMT 2015com.android.ex.variablespeed

VariableSpeedNative

public class VariableSpeedNative extends Object
Provides all the native calls through to the underlying audio library.

You should not use this class directly. Prefer to use the {@link VariableSpeed} class instead.

Fields Summary
Constructors Summary
Methods Summary
static native intgetCurrentPosition()

static native intgetTotalDuration()

static voidinitializeEngine(EngineParameters params)

        initializeEngine(params.getTargetFrames(),
                params.getWindowDuration(), params.getWindowOverlapDuration(),
                params.getMaxPlayBufferCount(), params.getInitialRate(),
                params.getDecodeBufferInitialSize(), params.getDecodeBufferMaxSize(),
                params.getStartPositionMillis(), params.getAudioStreamType());
    
private static native voidinitializeEngine(int targetFrames, float windowDuration, float windowOverlapDuration, int maxPlayBufferCount, float initialRate, int decodeBufferInitialSize, int decodeBufferMaxSize, int startPositionMillis, int audioStreamType)

static voidloadLibrary()

        System.loadLibrary("variablespeed");
    
static native voidplayFileDescriptor(int fd, long offset, long length)

static booleanplayFromContext(android.content.Context context, android.net.Uri uri)

        AssetFileDescriptor afd = context.getContentResolver().openAssetFileDescriptor(uri, "r");
        try {
            FileDescriptor fileDescriptor = afd.getFileDescriptor();
            Field descriptorField = fileDescriptor.getClass().getDeclaredField("descriptor");
            descriptorField.setAccessible(true);
            int fd = descriptorField.getInt(fileDescriptor);
            VariableSpeedNative.playFileDescriptor(fd, afd.getStartOffset(), afd.getLength());
            return true;
        } catch (SecurityException e) {
            // Fall through.
        } catch (NoSuchFieldException e) {
            // Fall through.
        } catch (IllegalArgumentException e) {
            // Fall through.
        } catch (IllegalAccessException e) {
            // Fall through.
        } finally {
            MoreCloseables.closeQuietly(afd);
        }
        return false;
    
static native voidplayUri(java.lang.String uri)

static native voidsetVariableSpeed(float speed)

static native voidshutdownEngine()

static native voidstartPlayback()

static native voidstopPlayback()