简体   繁体   中英

HTML 5 Video Player Customization for pausing after 10% of total video play back and it should stop

As per my clients requirement the video should be played for 10% of all the video playback time and it should pause after 10%, should ask for payment. If the user is already subscribed then he should not be prompted for payment. I'm considering video.js script. Is there any other player to implement the functionality or any code to do this. Please reply soon.

Thank you

First find out the duration of your video,

myVideoPlayer.addEventListener('loadedmetadata', function() {
    console.log(videoPlayer.duration);
});

Then calculate 10% of that duration . then pause the video after that time period using //assume requiredminutes variable is 10% of duration of video

myVideoPlayer.addEventListener("timeupdate", function(){
    if(this.currentTime >= requiredminutes * 60 * 1000) {
        this.pause();
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM