AV Help - didJustFinish not ever true? PlaybackObject sound attribute?

#1

According to the docs createAsync returns a PlaybackObject which has methods such as setOnPlayBackStatusUpdate. But, in my code I get an “undefined not a function” error trying to call such methods on the PlaybackObject. I have to go to myPBObj.sound to find those methods. Is this my mistake or are the docs out of date?

This “Example: Loop media exactly 20 times” example from the docs suggests that didJustFinish will be true at some point even if isLooping is true. But, in my code that doesn’t appear to be the case. I assume the progressUpdateIntervalMillis has no influence on whether the didJustFinish state will be visible.

myStatusUpdateFunction = (playbackObject, n) => {
let numberOfLoops = 0;
return playbackStatus => {
if (playbackStatus.didJustFinish) {
if (numberOfLoops === n - 1) {
playbackObject.setIsLoopingAsync(false);
playbackObject.setOnPlayBackStatusUpdate(undefined);
}
numberOfLoops += 1;
}
};
};

playbackObject.setOnPlaybackStatusUpdate(
  this.myStatusUpdateFunction(playbackObject,5)
);
playbackObject.setStatusAsync({
  isLooping: true,
  shouldPlay: true,
  positionMillis: 0,
});

Here’s the code. didJustFinish is never true here.

(I don’t know how to format code on this forum, sorry)

closed #2

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.