Code Monkey home page Code Monkey logo

Comments (5)

SamuelScheit avatar SamuelScheit commented on August 16, 2024

Can you show how you are calling the destroy function?

from puppeteer-stream.

ppoturalskiEC avatar ppoturalskiEC commented on August 16, 2024

Sorry for delay.

Here is a part of code that creates instance, page, stream and then destroys the stream.
Let me know if you need more details.

    // Create page
    const browser = await launch({
        // @ts-ignore
        product: 'chrome',
        headless: false,
        ignoreDefaultArgs: ['--mute-audio'],
        args: [
            '--autoplay-policy=no-user-gesture-required'
        ]
    })
    const page = await browser.newPage()
    
    (...)
    // Create stream
    const tabStream = await getStream(page,
        {
            audio: true,
            video: false
        }
    )
    
    (...)
    // Destroy stream
    await tabStream.destroy()

from puppeteer-stream.

diohabara avatar diohabara commented on August 16, 2024

I'm also having the same difficulty.

The node version is below.

node --version
v16.8.0

This is the code I wrote.

/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-call */
import * as puppeteerStream from 'puppeteer-stream';
import fs = require('fs');

const file = fs.createWriteStream(__dirname + '/test.webm');

async function test() {
  const options = {
    headless: false,
    args: ['--autoplay-policy=no-user-gesture-required'],
    ignoreDefaultArgs: ['--mute-audio'],
  };
  const browser = await puppeteerStream.launch(options);
  const page = await browser.newPage();
  const url = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
  await page.goto(url);

  // create a video stream
  const streamOptions: puppeteerStream.getStreamOptions = {
    audio: true,
    video: true,
  };
  const stream = await puppeteerStream.getStream(page as any, streamOptions);
  console.log('recording');

  stream.pipe(file);
  await timeout(5000);
  file.close();
  console.log('finished');
}

function timeout(ms: number) {
  return new Promise((resolve) => setTimeout(resolve, ms));
}

void (async () => {
  await test();
});

When I execute tsc --build, I got the following error.

$ tsc --build
node_modules/puppeteer-stream/dist/PuppeteerStream.d.ts:8:5 - error TS2416: Property 'destroy' in type 'Stream' is not assignable to the same property in base type 'Readable'.
  Type '(page?: Page) => Promise<void>' is not assignable to type '(error?: Error) => void'.
    Types of parameters 'page' and 'error' are incompatible.
      Type 'Error' is missing the following properties from type 'Page': _closed, _client, _target, _keyboard, and 118 more.

8     destroy(page?: Page): Promise<void>;
      ~~~~~~~


Found 1 error.

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

from puppeteer-stream.

kpachbiu88 avatar kpachbiu88 commented on August 16, 2024

node --version v16.13.0

Need to change destroy to destroyStream (for example) in files dist/puppeteerStream.d.ts line 8 and src/puppeteerStream.ts line 13

@Flam3rboy author?

from puppeteer-stream.

SamuelScheit avatar SamuelScheit commented on August 16, 2024

fixed with fef0a6f

from puppeteer-stream.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.