Skip to content

Unusable Object error #25

@gajrajgchouhan

Description

@gajrajgchouhan

Hi there,
I am getting an error of An attempt was made to use an object that is not, or is no longer, usable. Is this the right way to implement this library ?

async function pump() {
              const { done, value } = await reader.read();
              console.log({ value, done });
              if (done) {
                mediaSource.endOfStream();
                return;
              }
              // Decrypt the chunk
              // const decryptedChunk = await window.crypto.subtle.decrypt(
              //   {
              //     name: 'AES-CTR',
              //     counter: utils.incrementCounter(counter, offset),
              //     length: 64,
              //   },
              //   dekKey,
              //   value
              // );
              if (!isChrome) {
                for (const segment of audioWrapper.iterator(value)) {
                  sourceBuffer.appendBuffer(segment);
                }
              } else {
                sourceBuffer.appendBuffer(new Uint8Array(value));
              }
              console.log('decryption successful');
              isLoadedOnce.current = true;
              offset += value.byteLength;
              // Wait for the sourceBuffer to be ready for more data
              if (sourceBuffer.updating && sourceBuffer) {
                try {
                  await new Promise((resolve, reject) => {
                    sourceBuffer.addEventListener('updateend', resolve, { once: true });
                    sourceBuffer.addEventListener(
                      'error',
                      (e) => {
                        console.trace('Error waiting for updateend', e);
                        reject(e);
                      },
                      { once: true }
                    );
                  });
                } catch (error) {
                  console.trace('Error waiting for updateend', error);
                }
              }
              // Continue pumping
              void pump().catch((error) => {
                console.trace('Error pumping', error);
              });
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions