Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way i can stream the audio? #13

Closed
himanshu31shr opened this issue May 8, 2018 · 3 comments
Closed

Is there a way i can stream the audio? #13

himanshu31shr opened this issue May 8, 2018 · 3 comments

Comments

@himanshu31shr
Copy link

himanshu31shr commented May 8, 2018

It doesn't seem to stream the audio, rather it does download the whole file first making it quite slow.

@lijinke666
Copy link
Owner

@himanshu31shr Hi~ The component current version use <audio preload="auto"/> , so download the entire file as a result of initialization. that's so bad . i think should be remove preload attribute
I'm try use Web Audio Api suport stream , and download section in the next version .

@himanshu31shr
Copy link
Author

himanshu31shr commented May 12, 2018

@lijinke666 Sounds great! For now i managed to build api for streaming audio using node fs. Is there any other way around you know?

@lijinke666
Copy link
Owner

if you are use fs module . I'dont know your context is server ? are you server rendering?

if it is client , Should not be used fs

currently I'm still trying.

            const reader = new FileReader()
            reader.onload = (e) => {
                const result = e.target.result
                const audio = new AudioContext()
                audio.decodeAudioData(result, (buffer) => {    
                    const node = audio.createBufferSource()
                    node.buffer = buffer                    
                    node.connect(audio.destination)   
                    node.start(0)      
                }, (err) => {
                })
            }
            reader.readAsArrayBuffer(YOUR_DATA)   

or use URL.createObjectURL

audio.src = window.URL.createObjectURL(BLOB);

in the feat-audio-stream I have fixed some known bugs 。Audio loading has also become faster 。and I'm still trying something , We can also help each other。like pull a pr 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants