1

In an effort to get a seamless loop using OpenSL ES's URI player, I tried running the code, taken from this question (which queries the length of the audio):

SLmillisecond msec;
result = (*fdPlayerPlay)->GetDuration(fdPlayerPlay, &msec);
assert(SL_RESULT_SUCCESS == result);

__android_log_print(ANDROID_LOG_DEBUG, "NDK_debug_tag: ", "fdPlayerPlay GetDuration msec: %d", (int)msec);

I get -1 as a result, no matter what.

I can't seem to get anything other than whole file looping working. When I set the loop:

// enable whole file looping
result = (*uriPlayerSeek)->SetLoop(uriPlayerSeek, SL_BOOLEAN_TRUE, 0, 200);
assert(SL_RESULT_SUCCESS == result);

And then query the loop points:

    SLboolean b;
    SLmillisecond start;
    SLmillisecond end;

    result = (*uriPlayerSeek)->GetLoop(uriPlayerSeek, &b, &start, &end);
    assert(SL_RESULT_SUCCESS == result);

    __android_log_print(ANDROID_LOG_DEBUG, "NDK_debug_tag: ", "start: %d end: %d", (int)start, (int)end);

I get "start: 0 end: -1", and the file loops from start to finish, instead of just looping a small section (which is what I'm after). The documentation here only mentions whole file looping:

Seek

SetLoop enables whole file looping. The startPos parameter should be zero and the endPos parameter should be SL_TIME_UNKNOWN.

But it doesn't specifically say that looping part of a file is unsupported. Has anyone had any success with this? Or can verify that this feature is not supported by the OpenSL ES Android implementation?

Community
  • 1
  • 1
Michael J Petrie
  • 183
  • 4
  • 13

1 Answers1

0

I don't think this works for streams, I have not tested it but you might have to buffer in the entire sound data to do duration selections.

The -1 you get is SL_TIME_UNKNOWN (0xFFFFFFFF unsigned), the duration of the stream is unknown. If you just need the duration of the file it should exist in the header somewhere.

james82345
  • 530
  • 4
  • 13