Code Monkey home page Code Monkey logo

Comments (4)

jimmywarting avatar jimmywarting commented on May 20, 2024

Funny, just thought: "we already have FileReader, why not FileWriter?"

var writer = new FileWriter('filename')
writer.readAsBlob(blob)
writer.readAsSocket(new WebSocket)
writer.readAsStream(audioStream)

Maybe cuz it's a bad idéa and we have to support all of them.
perhaps just better to enforce a stream and build other function around that

How about:

var writer = new FileWriter(stream, 'filename')
// writer.methods? writer.close()

still think you should close it using the streams close method instead...
but then again, you maybe want to keep recording the camera without closing the the stream how do you then stop the writer?

let writeStream = createWriteStream("filename")
stream.pipeTo( writeStream )

writeStream.close()
// stream is still alive

from streamsaver.js.

jimmywarting avatar jimmywarting commented on May 20, 2024

One thing that i have experience when using this for a little while now with this syntax

saveStream(stream, "filename")

Is that: if you want to close the stream-saver you would need to close the stream you are trying to save...
I believe it's undesirable?
For example: I want to show a <video> tag what it looks like. But don't want to start recording until user press the record button. When I want to stop writing to the filesystem then I don't want to stop the <video> tag. I still want to show a preview of what it looks like.

I'm leaning more towards creating a createWriteStream('filename')
that way when you close the writer it will stop saving to the disk, and if you close the mediaStream it will signal to the writer (if you have piped it) that it should also close

from streamsaver.js.

jimmywarting avatar jimmywarting commented on May 20, 2024

@eligrey and everyone else do you have some spare time to look at the difference?

I have experience with both

saveStream(stream, "filename")

And also this: (checkout the Writable branch)

var myFile = fs.createWriteStream("filename")
myFile.write("abc")
// you could also do this:
let stream = fs.createBlobReader(blob)
stream.pipeTo(myFile)

What do you think is best?

from streamsaver.js.

jimmywarting avatar jimmywarting commented on May 20, 2024

I know now what i want...

from streamsaver.js.

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.