Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Making the audio file play only specific parts

My site wants to make sure that a user can make a sample of their song by entering the length of times where it should be played.

For example

4 min song.

The uploader specifies that only 1 minute to 2 minute plays

1 Community Answers


JW Player Support Agent  
0 rated :

We do not have built-in functionality to set a start time and end time for a video or song, but you can implement this using our Javascript API. My suggestion would be to use the seek() event to the desired start time when the video first starts to play with the .once(‘play’) event handler. Stopping at the desired time can be accomplished with a .stop() call when .getPosition() is greater than the desired end time. All of that would need to go in an .on(‘time’) function so the player knows to stop at the proper time.

The actual code looks something like this:


if (jwplayer().getPosition() >= end_time) {

Please note that when our player is in Flash mode, we cannot seek to unbuffered portions of a video, so you might not see the initial seek() call work correctly if you are trying to seek to a portion of the video that has not yet loaded.

This question has received the maximum number of answers.