Comments (7)
So, you can subscribe to "audioprocess" event and it's working, but it does not work with "finished", don't you?
If that is so, then event subscription through wavesurfer instance is working, however finished
event is not being fired for some reason that is, from my POV, wavesurfer.js
related.
Also, it may be, that "finished" is called after record is played up to the end.
from wavesurfer-react.
@Simoneth, I've tried to listen for "finish" event in demo fork.
The result is that this event is called when record playing is fully completed, it is not related to region or region play, because all you do to play region is just like make wavesurfer to play record's fragment, when "finish" is related to record.
It should also be taken into account, that the end of an audio can differ from the end of a region, so even if there would be a difference in a pair of milliseconds, then "finish" can be not fired...but this is just my assumption.
from wavesurfer-react.
@Simoneth, I think, that this question (how to listen to region play completed or simulate it) is more related to wavesurfer.js
repository. From my point of view, you can add a new listener for...audioprocess or progress event (I don't remember all the list), but with explicit aim to call some callback when progress will reach region's end...I will provide you with some pseudo code, but the rest is fully up to you:
function callbackFn () {
...some code...
} // or useCallback...
// It will save you from referencing issues withing listeners
const callbackRef = useRef(callbackFn);
function playRegion ({ start, end, ...restOfRegion }) {
ws.current.on("progress", (data) => {
if (data === end) {
callbackRef.current();
}
});
ws.current.play(
start,
rend
);
}
from wavesurfer-react.
@Simoneth, hi, did you try to check whether other events are being fired?
from wavesurfer-react.
@Simoneth, hi, did you try to check whether other events are being fired?
Hmm...it's strange, I can fire "audioprocess" but not "finish" and I have no idea why.
This is my function to start play, maybe it's related (I use regions):
wavesurferRef.current.play(
regionsRef.current[id].start,
regionsRef.current[id].end
);
from wavesurfer-react.
@Simoneth, I've tried to listen for "finish" event in demo fork.
The result is that this event is called when record playing is fully completed, it is not related to region or region play, because all you do to play region is just like make wavesurfer to play record's fragment, when "finish" is related to record.
It should also be taken into account, that the end of an audio can differ from the end of a region, so even if there would be a difference in a pair of milliseconds, then "finish" can be not fired...but this is just my assumption.
Since I use only regions, from Regions plugin page, I can't find any event that could fire the end of the region play...any workaround? It's just for my toggle button "Play / Stop"
from wavesurfer-react.
Here my simple solution:
useEffect(() => {
wavesurferRef.current.on("region-out", () => {
console.log("Track Finished");
});
}, [regions]);
from wavesurfer-react.
Related Issues (20)
- Waveform customisation HOT 2
- Can not get zoom to work HOT 5
- Cannot use import statement outside a module HOT 7
- recreate timeline if its id is changed HOT 1
- "Cannot use import statement outside a module" with Next.js HOT 3
- getCurrentTime without triggering too much re-render on the Component HOT 2
- Is it possible to use this with Tauri / NextJS SSG? HOT 2
- generating new markers in component wrapped by <StrictMode> not rendering new markers HOT 4
- wavesurfer-react with react-beautiful-dnd issue HOT 5
- Align the button- Should be at the bottom of each waveform HOT 1
- Support content for regions HOT 3
- Support for wavesurfer.js 7+ HOT 5
- wavesurfer-react: V3 HOT 18
- audio load issue HOT 2
- codesandbox code issue HOT 2
- add first-interaction github action
- improve demo webpage
- Minimap support HOT 1
- Issue with changing the style of the waveform scrollbar HOT 1
- How to get the list of all regions? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wavesurfer-react.