Skip to content

🎥 Make videos programmatically with React

getpriority

Jonny Burger460ccfbe8671
diff --git a/packages/media/src/audio/audio-preview-iterator.ts b/packages/media/src/audio/audio-preview-iterator.ts
index ec04920496..6181891253 100644
--- a/packages/media/src/audio/audio-preview-iterator.ts
+++ b/packages/media/src/audio/audio-preview-iterator.ts
@@ -281,16 +281,19 @@ export const makeAudioIterator = ({
audioChunksForAfterResuming.length = 0;
},
getNext: ({getPriority}: {getPriority: () => number}) => {
- return waitForTurn(getPriority, async () => {
- const next = await iterator.next();
- if (next.value) {
- mostRecentTimestamp = Math.max(
- mostRecentTimestamp,
- next.value.timestamp + next.value.duration,
- );
- }
-
- return next;
+ return waitForTurn({
+ getPriority,
+ fn: async () => {
+ const next = await iterator.next();
+ if (next.value) {
+ mostRecentTimestamp = Math.max(
+ mostRecentTimestamp,
+ next.value.timestamp + next.value.duration,
+ );
+ }
+
+ return next;
+ },
});
},
isDestroyed: () => {
diff --git a/packages/media/src/audio/sort-by-priority.ts b/packages/media/src/audio/sort-by-priority.ts
index 238351b6f7..8c08bcf0a3 100644
--- a/packages/media/src/audio/sort-by-priority.ts
+++ b/packages/media/src/audio/sort-by-priority.ts
@@ -42,10 +42,13 @@ const processNext = (): void => {
);
};
-export const waitForTurn = <T>(
- getPriority: () => number,
- fn: () => Promise<T>,
-): Promise<T> => {
+export const waitForTurn = <T>({
+ getPriority,
+ fn,
+}: {
+ getPriority: () => number;
+ fn: () => Promise<T>;
+}): Promise<T> => {
return new Promise<T>((resolve, reject) => {
waiters.push({
getPriority,