html video progress bar with js

kraven7771
Community Member Posts: 50
I'm working with Lectora 17, and I'm trying to figure out a way to have a custom playbar done with html and js.
I'm using a HTML video with the html extensions, and it seems a like most of my javascript is working expect for 2 crucial parts. The parts that updates the information on screen. I can see it working in console.log perfectly, but when it comes to updating the text on screen with the current time and add on to the width for the progressbar, they appear to be completely being ignored in the 'timeupdate' function. Does Lectora require an extra step to make this work or it needs to be done a different way? I've tested this on a regular HTML setup and it worked perfectly fine. I haven't found anything about this being an issue for anyone.
JS
$( document ).ready(function() {
var video = $("video")[0];
//Play/Pause control clicked
$('.btnPlay').on('click', function() {
if(video.paused) {
video.play();
}
else {
video.pause();
}
});
//get HTML5 video time duration
$("video").on('loadedmetadata', function() {
$('.duration').text(video.duration);
});
//update HTML5 video current play time
$("video").on('timeupdate', function() {
var currentPos = video.currentTime; //get currentime
var maxduration = video.duration; //get video duration
var percentage = (100 * currentPos / maxduration)+'%';
$('.currentPos').text(currentPos); //Not working
$('.timeBar').css('width', percentage); //Not working
console.log('currentPos: '+ currentPos);
console.log('percentage: '+ percentage);
});
});
I'm using a HTML video with the html extensions, and it seems a like most of my javascript is working expect for 2 crucial parts. The parts that updates the information on screen. I can see it working in console.log perfectly, but when it comes to updating the text on screen with the current time and add on to the width for the progressbar, they appear to be completely being ignored in the 'timeupdate' function. Does Lectora require an extra step to make this work or it needs to be done a different way? I've tested this on a regular HTML setup and it worked perfectly fine. I haven't found anything about this being an issue for anyone.
JS
$( document ).ready(function() {
var video = $("video")[0];
//Play/Pause control clicked
$('.btnPlay').on('click', function() {
if(video.paused) {
video.play();
}
else {
video.pause();
}
});
//get HTML5 video time duration
$("video").on('loadedmetadata', function() {
$('.duration').text(video.duration);
});
//update HTML5 video current play time
$("video").on('timeupdate', function() {
var currentPos = video.currentTime; //get currentime
var maxduration = video.duration; //get video duration
var percentage = (100 * currentPos / maxduration)+'%';
$('.currentPos').text(currentPos); //Not working
$('.timeBar').css('width', percentage); //Not working
console.log('currentPos: '+ currentPos);
console.log('percentage: '+ percentage);
});
});
Comments
-
figured it out,
Had to make all the variables global.
$( document ).ready(function() {
var video = $("video")[0];
var current = $('span.currentPos');
var time = $('div.timeBar');
var currentPos;
var maxduration;
var percentage;
//Play/Pause control clicked
$('.btnPlay').on('click', function() {
if(video.paused) {
video.play();
}
else {
video.pause();
}
});
//get HTML5 video time duration
$("video").on('loadedmetadata', function() {
$('.duration').text(video.duration);
});
//update HTML5 video current play time
$("video").on('timeupdate', function() {
currentPos = video.currentTime; //get currentime
maxduration = video.duration; //get video duration
percentage = (100 * currentPos / maxduration)+'%';
if(percentage === 'NaN%') {
percentage= "0%";
}
current.text(currentPos);
time.css('width', percentage);
$('.trythis').text('im working');
console.log('currentPos: '+ currentPos);
console.log('percentage: '+ percentage);
});
}); -
-
Hi,
I have a complete file setup available here.
It looks like you're on the right. I'm not sure how you're activating the action to get it to skip seconds.
Feel free to look at the file setup. I have skipping on videos setup on it too.
http://community.trivantis.com/forums/topic/custom-play-bar-with-html-extention/
Categories
- 4.7K All Categories
- 3 New Feature Releases
- The Training Arcade®
- Arcades™
- 57 ✫ Announcements
- 6 ✪ Contests
- 34.1K eLearning Brothers® Products
- 33.6K Lectora®
- 31.5K Lectora Discussions
- 1.9K Lectora Feature Requests
- 64 Lectora User Groups
- 16 Asset Library
- 10 AssetLibrary Discussions
- 6 AssetLibrary Feature Requests
- 293 CenarioVR®
- 171 CenarioVR Discussions
- 122 CenarioVR Feature Requests
- 29 Rockstar Learning Platform®
- 20 Rockstar Learning Platform Discussions
- 9 Rockstar Learning Platform Feature Requests
- 4 Off-the-Shelf Course Library
- 3 Off-the-Shelf Course Library Discussions
- 1 Off-the-Shelf Course Library Feature Requests
- 114 CourseMill®
- 107 CourseMill Discussions
- 43 ReviewLink®
- 31 ReviewLink Discussions
- 12 ReviewLink Suggestions
- 2 The Training Arcade®
- 1 The Training Arcade Discussions
- 1 The Training Arcade Feature Requests
- 10 Additional Learning Products
- 2 Adobe®
- 4 Articulate®
- 2 Camtasia®
- Docebo®
- 1 iSpring®
- 1 Microsoft® PowerPoint®
- 912 All Things eLearning
- 5 Course Development Showcase
- 1 eLearning Brothers® Downloads
- 1 Compliance Training
- 11 eLearning Development
- eLearning Game Design
- 7 Instructional Design
- 545 Learning Management System (LMS) Integration
- 2 Mobile Learning
- 5 Visual Design
- 329 Web Accessibility
- 1.2K ♪ The Green Room
- 7 ♡ Community Feedback
- 7 Community Tips