Giter VIP home page Giter VIP logo

Comments (6)

pkjy avatar pkjy commented on May 21, 2024

Thanks for your suggestion. I think the pcm data was played like stream ,the data is continuous send from the server or other side. In the current usage scenarios I encounter,when the pcm data comes from server we will need to play in the client side(like pc browser), and client side don't konw whether the audio is supposed to be end. So strictly speaking, it is difficult to judge whether this audio is really played out.

At the same time , I found AudioContext only has an event named statechange ,and it's fired when calling suspend or resume or close .

from pcm-player.

Evgenii-Gorbushin avatar Evgenii-Gorbushin commented on May 21, 2024

Thank you for your response)

I'll explain my idea more clearly, just for your information. In the code, there is the flush() method where BufferSource is created, like this:
var buffer Source = this.audioCtx.createBufferSource();
And BufferSource has a method called "onended", which fires whenever audio is played out. So, I modified the code, as you may see in an attached screenshot, and it works very well. It fires in a proper moment when streaming audio, which is located on an outside server, is played out.

Screenshot_2022 07 17_02

Best regards

from pcm-player.

pkjy avatar pkjy commented on May 21, 2024

Thank you for your response)

I'll explain my idea more clearly, just for your information. In the code, there is the flush() method where BufferSource is created, like this: var buffer Source = this.audioCtx.createBufferSource(); And BufferSource has a method called "onended", which fires whenever audio is played out. So, I modified the code, as you may see in an attached screenshot, and it works very well. It fires in a proper moment when streaming audio, which is located on an outside server, is played out.

Screenshot_2022 07 17_02

Best regards

yes, I also read this api, but every buffer is a small fragment, and this onended event will be fired many times. I don't know if this is useful or necessary. 😕

from pcm-player.

Evgenii-Gorbushin avatar Evgenii-Gorbushin commented on May 21, 2024

I need the onended event in my case of usage of pcm-player, so I had to add it manually. I would ask you to add the onended event as an option, as you did with statechange. Just make it optional in d.ts.
Thanks.

from pcm-player.

pkjy avatar pkjy commented on May 21, 2024

pls check v0.0.15

from pcm-player.

Evgenii-Gorbushin avatar Evgenii-Gorbushin commented on May 21, 2024

Thank you a lot, onended works fine :)

Also, I've tested onstatechange and got an issue in console on second run of pcm-player.

Screenshot_2022 07 19_01

Screenshot_2022 07 19_02

If I change the code like in the screenshot below the issue is gone.

Screenshot_2022 07 19_03

Best regards

from pcm-player.

Related Issues (9)

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.