Skip to content

🎥 Make videos programmatically with React

consider buffer offset as well

Jonny Burgerf6ebc8bbb46d
diff --git a/packages/media/src/audio/audio-preview-iterator.ts b/packages/media/src/audio/audio-preview-iterator.ts
index f693cdde68..ac33e4fced 100644
--- a/packages/media/src/audio/audio-preview-iterator.ts
+++ b/packages/media/src/audio/audio-preview-iterator.ts
@@ -252,7 +252,13 @@ export const makeAudioIterator = (
maxDuration: number | null,
bufferOffset: number,
) => {
- queuedAudioNodes.push({node, timestamp, buffer, maxDuration, bufferOffset});
+ queuedAudioNodes.push({
+ node,
+ timestamp,
+ buffer,
+ maxDuration,
+ bufferOffset,
+ });
},
removeQueuedAudioNode: (node: AudioBufferSourceNode) => {
const index = queuedAudioNodes.findIndex((n) => n.node === node);
diff --git a/packages/media/src/media-player.ts b/packages/media/src/media-player.ts
index b4ed3591a3..29cdb0fb51 100644
--- a/packages/media/src/media-player.ts
+++ b/packages/media/src/media-player.ts
@@ -306,7 +306,12 @@ export class MediaPlayer {
playbackRate: this.playbackRate * this.globalPlaybackRate,
startFromSecond: startTime,
getIsPlaying: () => this.playing,
- scheduleAudioNode: (node, mediaTimestamp, maxDuration, bufferOffset) => {
+ scheduleAudioNode: (
+ node,
+ mediaTimestamp,
+ maxDuration,
+ bufferOffset,
+ ) => {
if (!this.sharedAudioContext) {
throw new Error('Shared audio context not found');
}
@@ -403,7 +408,12 @@ export class MediaPlayer {
nonce,
playbackRate: this.playbackRate * this.globalPlaybackRate,
getIsPlaying: () => this.playing,
- scheduleAudioNode: (node, mediaTimestamp, maxDuration, bufferOffset) => {
+ scheduleAudioNode: (
+ node,
+ mediaTimestamp,
+ maxDuration,
+ bufferOffset,
+ ) => {
if (!this.sharedAudioContext) {
throw new Error('Shared audio context not found');
}
@@ -440,7 +450,12 @@ export class MediaPlayer {
if (this.audioIteratorManager) {
this.audioIteratorManager.resumeScheduledAudioChunks({
playbackRate: this.playbackRate * this.globalPlaybackRate,
- scheduleAudioNode: (node, mediaTimestamp, maxDuration, bufferOffset) => {
+ scheduleAudioNode: (
+ node,
+ mediaTimestamp,
+ maxDuration,
+ bufferOffset,
+ ) => {
if (!this.sharedAudioContext) {
throw new Error('Shared audio context not found');
}
@@ -594,7 +609,12 @@ export class MediaPlayer {
if (this.playing) {
this.audioIteratorManager.resumeScheduledAudioChunks({
playbackRate: this.playbackRate * this.globalPlaybackRate,
- scheduleAudioNode: (node, mediaTimestamp, maxDuration, bufferOffset) => {
+ scheduleAudioNode: (
+ node,
+ mediaTimestamp,
+ maxDuration,
+ bufferOffset,
+ ) => {
if (!this.sharedAudioContext) {
throw new Error('Shared audio context not found');
}