-
I want to increment the audio play count when certain percentage of the one audio clip has been played not just jumped to that position. What I'm doing now:
and on Play
and on Pause
and when the audio is playing executing the function to save the increment of play count if time is up.
But the problem is that the |
Beta Was this translation helpful? Give feedback.
Replies: 16 comments 8 replies
-
@haivala you can do |
Beta Was this translation helpful? Give feedback.
-
Sure I can do that but that shows percentage where the cursor is now. it does not take in account actual time listened. Am I right? |
Beta Was this translation helpful? Give feedback.
-
Why was this closed? |
Beta Was this translation helpful? Give feedback.
-
@haivala you also have the option to use |
Beta Was this translation helpful? Give feedback.
-
I know that I have that option but that does not take into account actual time user has really played the track. |
Beta Was this translation helpful? Give feedback.
-
@haivala |
Beta Was this translation helpful? Give feedback.
-
What I'm looking is to make sure the user has played for example 30% of the audio and then increment the play count. This includes situations where user starts to play and then skips to lets say to 50% and plays the track to 80%. This means that I need to keep track on how many seconds user has listened current audio compared the total length of the track and when the time is up fire an event. Example is in the first post. |
Beta Was this translation helpful? Give feedback.
-
Isn't this something Spotify and others do. They don't you let you spam play count and pay the artists for it. |
Beta Was this translation helpful? Give feedback.
-
@haivala this count should be happening on backend type websocket stream to avoid spamming but if you want to do it on frontend then you should be able to do something like this: https://www.entonbiba.com/lab/wavesurfer/2623.html var totalPlays = 0;
var totalTime = 0;
var playInterval;
wavesurfer.on("play", function() {
playInterval = setInterval(() => {
totalTime = totalTime + 100
$('#totalTime').html(totalTime);
if(totalTime>=30000){
totalPlays = 1;
$('#totalPlays').html(totalPlays);
totalTime = 0;
}
}, 100);
});
wavesurfer.on("pause", function() {
clearInterval(playInterval);
});
wavesurfer.on("stop", function() {
clearInterval(playInterval);
});
wavesurfer.on("finish", function() {
clearInterval(playInterval);
}); |
Beta Was this translation helpful? Give feedback.
-
Again from the first comment:
|
Beta Was this translation helpful? Give feedback.
-
@haivala if you find a way to track audio progress when the tab is not in focus, feel free to propose a new wavesurfer event. |
Beta Was this translation helpful? Give feedback.
-
Can we open this issue as it is not solved? |
Beta Was this translation helpful? Give feedback.
-
I don't think it's an actionable issue that we should track. My perspective is, the GH issues are our task manager. From the feedback that you've already received here, unfortunately nobody seems know what other event we could add, so there's no concrete idea to implement. If you'd like more feedback, we can move the discussion to the forum for visibility. Ultimately, we're open to adding a new wavesurfer.js event. If you do some research and find a way this can work, please feel free to make a pull request. |
Beta Was this translation helpful? Give feedback.
-
If we're talking about the MediaElement API, perhaps
Can you test it in your app? If it works, we can expose this event in the wavesurfer API. |
Beta Was this translation helpful? Give feedback.
-
Now that v7 is out is there better way to do this? |
Beta Was this translation helpful? Give feedback.
If we're talking about the MediaElement API, perhaps
timeupdate
would be worth trying.I've briefly tested this in Chrome, and it seems to fire this event even when you're in another tab:
Can you test it in your app? If it works, we can expose this event in the wavesurfer API.